I'm building an e-commerce website were I have several types of
products each extending a base product model.
I want to use django-polymorphic but afraid that it'll break upgrade
path in next versions of django.
Can you explain how the queryset work and what changes does django-
polymorphic does to the db compared to the usual model inheritance?
Is there a chance that this will be included with django in the
future?
The functionality in this project is amazing.
Thanks
> I want to use django-polymorphic but afraid that it'll break upgrade
> path in next versions of django.
In general, django_polymorphic mostly leverages functionality already
present in Django in order to create a consistent polymorphic
programming interface. It implements its functionality mostly on top
of the stable API of the normal Django ORM.
There is a little trickery at some points, which however I believe is
non-critical. An example is the __getattribute__ member function of
PolymorphicModel (I will try to get a small patch accepted for Django
1.3 which would get rid of that).
Originally I developed django_polymorphic for Django 1.1. There were
some major internal changes in the ORM of Django 1.2, but
django_polymorphic just worked out of the box with V1.2 alpha/beta -
no changes were needed for 1.2 (but Django 1.2 offers new worthwhile
features that django_polymorphic now uses if it detects V1.2).
I'm confident that future versions of Django will only require minor
changes/fixes to django_polymorphic.
> Can you explain how the queryset work and what changes does django-
> polymorphic does to the db compared to the usual model inheritance?
The DB schema is the standard Django model inheritance schema. The
only addition to the DB schema is the field "polymorphic_ctype" (a
standard Django ContentType db field) to the model directly inheriting
from PolymorphicModel (done through the standard Django model
inheritance mechanism). This means you can use the polymorphic db
tables and their existing data just normally without
django_polymorphic, using the vanilla Django ORM.
The polymorphic queryset pretty much only translates the polymorphic
API to the standard Django queryset API. This is very straightforward.
You can read more about the details in the docstrings in polymorphic/
query.py.
> Is there a chance that this will be included with django in the future?
I believe that it's a better goal to make sure that future versions of
Django do not really break django_polymorphic as an external module.
In the worst case, if enough people publicly cry "ouch" if Django 1.3
alpha or Django 1.4 alpha break things in horrible ways (as unlikely
as that may be), then that should be enough to avoid that.
> The functionality in this project is amazing.
Thanks for your praise!
Kind Regards,
Bert Constantin