I've got a few classes that inherit from an abstract class.  At some
point, I want to check and make sure that an object is an instance of
the base class, but this always seems to fail. I've posted what I know
and what I think may be relevant below.

Is isinstance() not matching because the RequisitionOrderItem.__mro__
classes have decotrack (my project) prepended, while OrderItem does
not?   Why is this?  They come from the same models.py

# base/models.py
#
# class OrderItem(models.Model):
#    ...
#    class Meta:
#        abstract = True
#
# class RequisitionOrderItem(OrderItem):
#    ...

>>> from base.models import OrderItem, RequisitionOrderItem
>>> RequisitionOrderItem.__mro__
(<class 'decotrack.base.models.RequisitionOrderItem'>, <class
'decotrack.base.models.OrderItem'>, <class
'django.db.models.base.Model'>, <type 'object'>)
>>> OrderItem.__mro__
(<class 'base.models.OrderItem'>, <class
'django.db.models.base.Model'>, <type 'object'>)
>>> roi = RequisitionOrderItem.objects.all()[0]
>>> isinstance(roi, RequisitionOrderItem)
True
>>> isinstance(roi, OrderItem)
False
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to