Getting a subclass from an abstract Model
Hello everyone,
my models are defined like this:
class MyBaseModel(models.Model):
.....
class Meta:
abstract = True
class ClassA(MyBaseModel):
......
class ClassB(MyBaseModel):
......
Then I'm trying to get a subclass of MyBaseModel by doing this:
for s in MyBaseModel.__subclasses__():
if s.__name__ == "ClassA":
MyClass = s
elif s.__name__ == "ClassB":
MyClass = s
q = MyClass.objects.all() ===> Raise an AttributeError: type object
'ClassA' has no attribute '_default_manager'
I don't understand why it raises this error, what am I missing?
Thank you very much for your help.
Cheers,
Gontran
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home