I have a BaseModel and n models that subclass it.
Each instance of the BaseClass has a .name_of_subclass attribute that
returns the subclass instance associated with it.
Is there a generic way of accessing this instance without knowing
beforehand the name of the subclass, something like
base_class_instance.generic_subclass_instance?

Example:

class BaseModel(models.Model):
    visible = models.BooleanField(default=True)

class OneSubModel(BaseModel):
   palatable = models.BooleanField(default=True)

class OtherRandomSubModel(BaseModel):
   palatable = models.BooleanField(default=True)

for base_class_instance in BaseModel.objects.filter(visible=True):
    print base_class_instance.generic_subclass_instance.palatable()
--~--~---------~--~----~------------~-------~--~----~
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