What about integrating polymorphic features in the ORM? It's like having 
the features of django-polymorphic but in the core.

The polymorphism could be acheved by:
    1. Having contenttypes installed (this is a common pattern).
    2. Specifying a root (first ancestor) model class like:

    class MyParentModel(models.Model):
        ...

        class Meta:
            polymorphic = True
            discriminant = "somefield" #it could default to 'content_type' 
if not specified. This field could be created.

To achieve the polymorphism a query could be like:

    objects = 
MyParentModel.objects.filter(foo=bar,baz=clorch,...).polymorphic().more().calls().ifneeded()

Such method could complain if the contenttypes application is not 
installed; it could be based on many select_related() arguments (which are 
collected by tree-traversing the hierarchy, perhaps ignoring proxies).
Alternatively, this could be an util in the contenttypes app instead of the 
core apps:

    objects = 
contenttypes.utils.polymorphic(MyParentModel.objects.filter(foo=bar,baz=clorch,...)).more().calls().ifneeded()

Sorry if this was posted before, but it's my first time here and I always 
asked why does Django not have this feature in the core.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/56023d31-de23-4d0a-92d4-be78d8149089%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to