code is getting executed when Django validates it's models. Hence, 
Cartprobably has not been validated yet and it's model class is 
None.

On Monday, February 11, 2013 4:29:44 PM UTC+5:30, vijay shanker wrote:
>
> hi 
> i wrote a function for producing tuples of all model names, which is this:
> from django.contrib.contenttypes.models import ContentType
> from django.db.models.loading import get_model
>
> def get_all_models():
>     return tuple([(each.__module__+'.'+each.__name__,each.__name__) for 
> each in [each.model_class() for each in 
> ContentType.objects.filter(app_label__in=['products','productoptions','shoppingcart'])
>  
> if each is not None] if each is not None])
>     
> when i run this in my shell it gives this output:
>
> (('shoppingcart.models.Cart', 'Cart'), ('shoppingcart.models.CartItem', 
> 'CartItem'), ('shoppingcart.models.CartRule', 'CartRule'), 
> ('products.models.CasesAccessory', 'CasesAccessory'), 
> ('productoptions.models.Coating', 'Coating'), 
> ('shoppingcart.models.ConditionSet', 'ConditionSet'), 
> ('products.models.Eyeglass', 'Eyeglass'), ('products.models.GiftVoucher', 
> 'GiftVoucher'), ('productoptions.models.Lens', 'Lens'), 
> ('productoptions.models.Prescription', 'Prescription'), 
> ('products.models.Readingglass', 'Readingglass'), 
> ('products.models.Sunglass', 'Sunglass'), ('productoptions.models.Tint', 
> 'Tint'), ('productoptions.models.Vision', 'Vision'))
>
> while at choices my first option got lost and output is:
>
> (('shoppingcart.models.CartItem', 'CartItem'), 
> ('products.models.CasesAccessory', 'CasesAccessory'), 
> ('productoptions.models.Coating', 'Coating'), ('products.models.Eyeglass', 
> 'Eyeglass'), ('products.models.GiftVoucher', 'GiftVoucher'), 
> ('productoptions.models.Lens', 'Lens'), 
> ('productoptions.models.Prescription', 'Prescription'), 
> ('products.models.Readingglass', 'Readingglass'), 
> ('products.models.Sunglass', 'Sunglass'), ('productoptions.models.Tint', 
> 'Tint'), ('productoptions.models.Vision', 'Vision'))
>
> why did this happened and whats the fix ?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to