Sunday, January 1, 2012

Getting children of an ABC

I am using Django 1.3.1 and I have the following piece of models:

class masterData(models.Model):
uid = models.CharField(max_length=20,primary_key=True)

class Meta:
abstract = True;

class Type1(masterData):
pass;

class Type2(masterData):
pass;

Now, I am trying to get a list of all child classes of masterData. I
have tried:

masterData.__subclasses__()

The very interesting thing that I found about the above is that it
works flawlessly in *python manage.py shell* and does NOT work at all
when running the webserver!

So how do I get the models derived from an Abstract Base Class model ?

Regards,
Samar

--
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.

No comments:

Post a Comment