Changelog¶
v4.10.2 (2026-01-14)¶
v4.10.1 (2026-01-13)¶
v4.10.0 (2026-01-13)¶
This release is primarily an integrations release. Many tests were added for the documented intergrations and a few bugs were fixed. Some warnings were converted to system checks. The two most notable changes are:
The django-rest-polymorphic package is now part of django-polymorphic.
In queries that need content types that are not cached those fetches are now embedded as subqueries. This reduces the total number of queries needed but most importantly it eliminates a class of errors that could happen if Manager/QuerySet methods that should not but do generate database queries are called before models are loaded (e.g. get_queryset()).
Issues¶
Implemented Bring django-rest-polymorphic into this package.
Tip
django-rest-polymorphic is now part of django-polymorphic. You must update your import paths from
rest_polymorphic.serializerstopolymorphic.contrib.drf.serializers.Fixed Guardian contenttype integraton hook is extremely brittle
Fixed Models defined after load break inheritance utility caches
Implemented System check error for PolymorphicManager marked as use_in_migrations
Implemented Manager warnings should be system checks instead.
v4.9.0 (2026-01-09)¶
Note
This update may generate new migrations for your polymorphic models, similar to the following. This is ok and an expected side effect of fixing #815
migrations.AlterModelOptions(
name='modelname',
options={},
)
v4.8.0 (2026-01-08)¶
v4.7.0 (2026-01-07)¶
Fixed a few outstanding admin bugs, updated documentation and added more admin tests for things like m2m relationships.
v4.6.0 (2026-01-05)¶
The release fixes longstanding bugs with respect to expected ORM behavior. For a complete list of changes see the v4.6.0 release.
Fixed get_real_instance() should also gracefully retry parents on failure (best effort)
Fixed polymorphic_primary_key_name no longer points to base classes polymorphic field
Fixed PolymorphicChildModelAdmin with show_in_index=False in Django Admin with nav_sidebar
Fixed ForeignKeyViolation when trying to save an entity when using a non-default db
Fixed Content types pulled from wrong database when using database routers
Fixed Copying Polymorphic objects for below the first level not working
Fixed Getting a specific element from a queryset in an post_delete returns None
Fixed Reverse related object descriptor is overwritten on class
v4.3.1, v4.4.2, v4.5.2 (2026-01-01)¶
v4.5.1 (2025-12-24)¶
v4.5.0 (2025-12-22)¶
The release fixes longstanding bugs with respect to deletion of polymorphic models.
Warning
This version has a bug that generates unnecessary migrations - use 4.5.1 instead!
Implemented Deletion fixes This release fixes the longstanding polymorphic deletion bug. The fix should be transparent and not generate new migrations files. If you experience any issues, please report them.
Fixed AttributeError Using .alias() On Polymorphic Querysets
v4.4.1 (2025-12-15)¶
v4.4.0 (2025-12-14)¶
v4.3.0 (2025-12-09)¶
v4.2.0 (2025-12-04)¶
Implemented Defer to chunk_size parameter on .iterators for fetching get_real_instances()
Fixed Show full admin context (breadcrumb and logout nav) in model type selection admin form
Fixed Issue with Autocomplete Fields in StackedPolymorphicInline.Child Inline
Support Python 3.14 and Django 6.0, drop support for EOL python 3.9, Django 3.2, 4.0, 4.1 and 5.0.
Modernized package management with new build, test, docs tooling and improved CI.
v4.1.0 (2025-05-20)¶
v4.0.0 (2025-05-20)¶
There were no breaking changes in this major release
This was the first release under Jazzband.
There were many updates modernizing the package and incorporating Jazzband standards:
Updates to documentation
Formatting and linting with ruff
Moving to GHA from Travis CI
Switch to pytest
Changes that touched the core package code were:
Replace string formats with f-strings
- Removed deprecated usage of package_resources
as of Python 3.12 package_resources was removed. To get prior releases to work on >3.12 you would also need to install setuptools.
v3.1.0 (2021-11-18)¶
Added support for Django 4.0.
Fixed crash when the admin “add type” view has no choices; will show a permission denied.
Fixed missing
localefolder in sdist.Fixed missing
QuerySet.bulk_create(.., ignore_conflicts=True)parameter support.Fixed
FilteredRelationsupport.Fixed supporting class keyword arguments in model definitions for
__init_subclass__().Fixed including
polymorphic.tests.migrationsin the sdist.Fixed non-polymorphic parent handling, which has no
_base_objects.Fixed missing
widgetssupport formodelform_factory().Fixed
has_changedhandling forpolymorphic_ctype_iddue to implicit str to int conversions.Fixed
Qobject handling when lists are used (e.g. in django-advanced-filters).Fixed Django Admin support when using a script-prefix.
Many thanks to everyone providing clear pull requests!
v3.0.0 (2020-08-21)¶
Support for Django 3.X
Dropped support for python 2.X
A lot of various fixes and improvements by various authors. Thanks a lot!
v2.1.2 (2019-07-15)¶
Fix
PolymorphicInlineModelAdminmedia jQuery include for Django 2.0+
v2.1.1 (2019-07-15)¶
Fixed admin import error due to
isortchanges.
v2.1 (2019-07-15)¶
Added Django 2.2 support.
Changed
.non_polymorphic(), to use a different iterable class that completely circumvent polymorphic.Changed SQL for
instance_offilter: useINstatement instead ofORclauses.Changed queryset iteration to implement
prefetch_related()support.Fixed Django 3.0 alpha compatibility.
Fixed compatibility with current django-extra-views in
polymorphic.contrib.extra_views.Fixed
prefetch_related()support on polymorphic M2M relations.Fixed model subclass
___selector for abstract/proxy models.Fixed model subclass
___selector for models with a customOneToOneField(parent_link=True).Fixed unwanted results on calling
queryset.get_real_instances([]).Fixed unwanted
TypeErrorexception whenPolymorphicTypeInvalidshould have raised.Fixed hiding the add-button of polymorphic lines in the Django admin.
Reformatted all files with black
v2.0.3 (2018-08-24)¶
Fixed admin crash for Django 2.1 with missing
use_required_attribute.
v2.0.2 (2018-02-05)¶
Fixed manager inheritance behavior for Django 1.11, by automatically enabling
Meta.manager_inheritance_from_futureif it’s not defined. This restores the manager inheritance behavior that django-polymorphic 1.3 provided for Django 1.x projects.Fixed internal
base_objectsusage.
v2.0.1 (2018-02-05)¶
Fixed manager inheritance detection for Django 1.11.
It’s recommended to use
Meta.manager_inheritance_from_futureso Django 1.x code also inherit thePolymorphicManagerin all subclasses. Django 2.0 already does this by default.Deprecated the
base_objectsmanager. Useobjects.non_polymorphic()instead.Optimized detection for dumpdata behavior, avoiding the performance hit of
__getattribute__().Fixed test management commands
v2.0.0 (2018-01-22)¶
BACKWARDS INCOMPATIBILITY: Dropped Django 1.8 and 1.10 support.
BACKWARDS INCOMPATIBILITY: Removed old deprecated code from 1.0, thus:
Import managers from
polymorphic.managers(plural), notpolymorphic.manager.Register child models to the admin as well using
@admin.register()oradmin.site.register(), as this is no longer done automatically.
Added Django 2.0 support.
Also backported into 1.3.1:
Added
PolymorphicTypeUndefinedexception for incomplete imported models. When a data migration or import creates an polymorphic model, thepolymorphic_ctype_idfield should be filled in manually too. Thepolymorphic.utils.reset_polymorphic_ctypefunction can be used for that.Added
PolymorphicTypeInvalidexception when database was incorrectly imported.Added
polymorphic.utils.get_base_polymorphic_model()to find the base model for types.Using
base_modelon the polymorphic admins is no longer required, as this can be autodetected.Fixed manager errors for swappable models.
Fixed
deleteTextof|as_script_optionstemplate filter.Fixed
.filter(applabel__ModelName___field=...)lookups.Fixed proxy model support in formsets.
Fixed error with .defer and child models that use the same parent.
Fixed error message when
polymorphic_ctype_idis null.Fixed fieldsets recursion in the admin.
Improved
polymorphic.utils.reset_polymorphic_ctype()to accept models in random ordering.Fix fieldsets handling in the admin (
declared_fieldsetsis removed since Django 1.9)
v1.3.1 (2018-04-16)¶
Backported various fixes from 2.x to support older Django versions:
Added
PolymorphicTypeUndefinedexception for incomplete imported models. When a data migration or import creates an polymorphic model, thepolymorphic_ctype_idfield should be filled in manually too. Thepolymorphic.utils.reset_polymorphic_ctypefunction can be used for that.Added
PolymorphicTypeInvalidexception when database was incorrectly imported.Added
polymorphic.utils.get_base_polymorphic_model()to find the base model for types.Using
base_modelon the polymorphic admins is no longer required, as this can be autodetected.Fixed manager errors for swappable models.
Fixed
deleteTextof|as_script_optionstemplate filter.Fixed
.filter(applabel__ModelName___field=...)lookups.Fixed proxy model support in formsets.
Fixed error with .defer and child models that use the same parent.
Fixed error message when
polymorphic_ctype_idis null.Fixed fieldsets recursion in the admin.
Improved
polymorphic.utils.reset_polymorphic_ctype()to accept models in random ordering.Fix fieldsets handling in the admin (
declared_fieldsetsis removed since Django 1.9)
v1.3.0 (2017-08-01)¶
BACKWARDS INCOMPATIBILITY: Dropped Django 1.4, 1.5, 1.6, 1.7, 1.9 and Python 2.6 support. Only official Django releases (1.8, 1.10, 1.11) are supported now.
Allow expressions to pass unchanged in
.order_by()Fixed Django 1.11 accessor checks (to support subclasses of
ForwardManyToOneDescriptor, likeForwardOneToOneDescriptor)Fixed polib syntax error messages in translations.
v1.2.0 (2017-05-01)¶
Django 1.11 support.
Fixed
PolymorphicInlineModelAdminto explictly excludepolymorphic_ctype.Fixed Python 3 TypeError in the admin when preserving the query string.
Fixed Python 3 issue due to
force_unicode()usage instead offorce_text().Fixed
z-indexattribute for admin menu appearance.
v1.1.0 (2017-02-03)¶
Added class based formset views in
polymorphic/contrib/extra_views.Added helper function
polymorphic.utils.reset_polymorphic_ctype(). This eases the migration old existing models to polymorphic.Fixed Python 2.6 issue.
Fixed Django 1.6 support.
v1.0.2 (2016-10-14)¶
Added helper function for django-guardian; add
GUARDIAN_GET_CONTENT_TYPE = 'polymorphic.contrib.guardian.get_polymorphic_base_content_type'to the project settings to let guardian handles inherited models properly.Fixed
polymorphic_modelformset_factory()usage.Fixed Python 3 bug for inline formsets.
Fixed CSS for Grappelli, so model choice menu properly overlaps.
Fixed
ParentAdminNotRegisteredexception for models that are registered via a proxy model instead of the real base model.
v1.0.1 (2016-09-11)¶
Fixed compatibility with manager changes in Django 1.10.1
v1.0.0 (2016-09-02)¶
Added Django 1.10 support.
Added admin inline support for polymorphic models.
Added formset support for polymorphic models.
Added support for polymorphic queryset limiting effects on proxy models.
Added support for multiple databases with the
.using()method andusing=..keyword argument.Fixed modifying passed
Q()objects in place.
Note
This version provides a new method for registering the admin models. While the old method is still supported, we recommend to upgrade your code. The new registration style improves the compatibility in the Django admin.
Register each
PolymorphicChildModelAdminwith the admin site too.The
child_modelsattribute of thePolymorphicParentModelAdminshould be a flat list of all child models. The(model, admin)tuple is obsolete.
Also note that proxy models will now limit the queryset too.
Fixed since 1.0b1 (2016-08-10)¶
Fix formset empty-form display when there are form errors.
Fix formset empty-form hiding for Grappelli.
Fixed packing
admin/polymorphic/edit_inline/stacked.htmlin the wheel format.
v0.9.2 (2016-05-04)¶
Fix error when using
date_hierarchyfield in the adminFixed Django 1.10 warning in admin add-type view.
v0.9.1 (2016-02-18)¶
Fixed support for
PolymorphicManager.from_queryset()for custom query sets.Fixed Django 1.7
changeform_view()redirection to the child admin site. This fixes custom admin code that uses these views, such as django-reversion’srevision_view()/recover_view().Fixed
.only('pk')field support.Fixed
object_history_templatebreadcrumb. NOTE: when using django-reversion / django-reversion-compare, make sure to implement aadmin/polymorphic/object_history.htmltemplate in your project that extends fromreversion/object_history.htmlorreversion-compare/object_history.htmlrespectively.
v0.9.0 (2016-02-17)¶
Added
.only()and.defer()support.Added support for Django 1.8 complex expressions in
.annotate()/.aggregate().Fix Django 1.9 handling of custom URLs. The new change-URL redirect overlapped any custom URLs defined in the child admin.
Fix Django 1.9 support in the admin.
Fix setting an extra custom manager without overriding the
_default_manager.Fix missing
history_view()redirection to the child admin, which is important for django-reversion support. See the documentation for hints for django-reversion-compare support <https://github.com/jazzband/django-polymorphic/discussions/831>_.
v0.8.1 (2015-12-29)¶
Fixed support for reverse relations for
relname___fieldwhen the field starts with an_character. Otherwise, the query will be interpreted as subclass lookup (ClassName___field).
v0.8.0 (2015-12-28)¶
Added Django 1.9 compatibility.
Renamed
polymorphic.manager=>polymorphic.managersfor consistentcy.BACKWARDS INCOMPATIBILITY: The import paths have changed to support Django 1.9. Instead of
from polymorphic import X, you’ll have to import from the proper package. For example:
from polymorphic.models import PolymorphicModel
from polymorphic.managers import PolymorphicManager, PolymorphicQuerySet
from polymorphic.showfields import ShowFieldContent, ShowFieldType, ShowFieldTypeAndContent
BACKWARDS INCOMPATIBILITY: Removed
__version__.pyin favor of a standard__version__inpolymorphic/__init__.py.BACKWARDS INCOMPATIBILITY: Removed automatic proxying of method calls to the queryset class. Use the standard Django methods instead:
# In model code:
objects = PolymorphicQuerySet.as_manager()
# For manager code:
MyCustomManager = PolymorphicManager.from_queryset(MyCustomQuerySet)
v0.7.2 (2015-10-01)¶
Added
queryset.as_manager()support for Django 1.7/1.8Optimize model access for non-dumpdata usage; avoid
__getattribute__()call each time to access the manager.Fixed 500 error when using invalid PK’s in the admin URL, return 404 instead.
Fixed possible issues when using an custom
AdminSiteclass for the parent object.Fixed Pickle exception when polymorphic model is cached.
v0.7.1 (2015-04-30)¶
Fixed Django 1.8 support for related field widgets.
v0.7.0 (2015-04-08)¶
Added Django 1.8 support
Added support for custom primary key defined using
mybase_ptr = models.OneToOneField(BaseClass, parent_link=True, related_name="...").Fixed Python 3 issue in the admin
Fixed
_default_managerto be consistent with Django, it’s now assigned directly instead of usingadd_to_class()Fixed 500 error for admin URLs without a ‘/’, e.g.
admin/app/parentmodel/id.Fixed preserved filter for Django admin in delete views
Removed test noise for diamond inheritance problem (which Django 1.7 detects)
v0.6.1 (2014-12-30)¶
Remove Django 1.7 warnings
Fix Django 1.4/1.5 queryset calls on related objects for unknown methods. The
RelatedManagercode overridesget_query_set()while__getattr__()used the new-styleget_queryset().Fix validate_model_fields(), caused errors when metaclass raises errors
v0.6.0 (2014-10-14)¶
Added Django 1.7 support.
Added permission check for all child types.
BACKWARDS INCOMPATIBILITY: the
get_child_type_choices()method receives 2 arguments now (request, action). If you have overwritten this method in your code, make sure the method signature is updated accordingly.
v0.5.6 (2014-07-21)¶
Added
pk_regexto thePolymorphicParentModelAdminto support non-integer primary keys.Fixed passing
?ct_id=to the add view for Django 1.6 (fixes compatibility with django-parler).
v0.5.5 (2014-04-29)¶
Fixed
get_real_instance_class()for proxy models (broke in 0.5.4).
v0.5.4 (2014-04-09)¶
Fix
.non_polymorphic()to returns a clone of the queryset, instead of effecting the existing queryset.Fix missing
alters_data = Trueannotations on the overwrittensave()methods.Fix infinite recursion bug in the admin with Django 1.6+
Added detection of bad
ContentTypetable data.
v0.5.3 (2013-09-17)¶
Fix TypeError when
base_formwas not defined.Fix passing
/admin/app/model/id/XYZurls to the correct admin backend. There is no need to include a?ct_id=..field, as the ID already provides enough information.
v0.5.2 (2013-09-05)¶
Fix Grappelli breadcrumb support in the views.
Fix unwanted
___handling in the ORM when a field name starts with an underscore; this detects you meantrelatedfield__ _underscorefieldinstead ofClassName___field.Fix missing permission check in the “add type” view. This was caught however in the next step.
Fix admin validation errors related to additional non-model form fields.
v0.5.1 (2013-07-05)¶
Add Django 1.6 support.
Fix Grappelli theme support in the “Add type” view.
v0.5.0 (2013-04-20)¶
Add Python 3.2 and 3.3 support
Fix errors with ContentType objects that don’t refer to an existing model.
v0.4.2 (2013-04-10)¶
Used proper
__version__marker.
v0.4.1 (2013-04-10)¶
Add Django 1.5 and 1.6 support
Add proxy model support
Add default admin
list_filterfor polymorphic model type.Fix queryset support of related objects.
Performed an overall cleanup of the project
Deprecated the
queryset_classargument of thePolymorphicManagerconstructor, use the class attribute instead.Dropped Django 1.1, 1.2 and 1.3 support
v0.4.0 (2013-03-25)¶
Update example project for Django 1.4
Added tox and Travis configuration
v0.3.1 (2013-02-28)¶
SQL optimization, avoid query in pre_save_polymorphic()
v0.3.0 (2013-02-28)¶
Many changes to the codebase happened, but no new version was released to pypi for years. 0.3 contains fixes submitted by many contributors, huge thanks to everyone!
Added a polymorphic admin interface.
PEP8 and code cleanups by various authors
v0.2.0 (2011-04-27)¶
The 0.2 release serves as legacy release. It supports Django 1.1 up till 1.4 and Python 2.4 up till 2.7.
V1.0 Release Candidate 1 (2011-01-24)¶
Fixed GitHub issue 15 (query result incomplete with inheritance). Thanks to John Debs for reporting and the test case.
Renaming, refactoring, new maintainer (2011-12-20)¶
Since the original author disappeared from the internet, we undertook to maintain and upgrade this piece of software.
The latest “legacy” tag should be V1.0-RC-1. Anything above that should be considered experimental and unstable until further notice (there be dragons).
New features, bug fixes and other improvements will be added to trunk from now on.
V1.0 Beta 2 (2010-11-11)¶
Beta 2 accumulated somewhat more changes than intended, and also has been delayed by DBMS benchmark testing I wanted to do on model inheritance. These benchmarks show that there are considerable problems with concrete model inheritance and contemporary DBM systems. The results will be forthcoming on the google discussion forum.
Please also see: http://www.jacobian.org/writing/concrete-inheritance/
The API should be stable now with Beta 2, so it’s just about potential bugfixes from now on regarding V1.0.
Beta 2 is still intended for testing and development environments and not for production. No complaints have been heard regarding Beta 1 however, and Beta 1 is used on a few production sites by some enterprising users.
There will be a release candidate for V1.0 in the very near future.
New Features and changes¶
API CHANGE:
.extra()has been re-implemented. Now it’s polymorphic by default and works (nearly) without restrictions (please see docs). This is a (very) incompatible API change regarding previous versions of django_polymorphic. Support for thepolymorphickeyword parameter has been removed. You can get back the non-polymorphic behaviour by usingModelA.objects.non_polymorphic().extra(...).API CHANGE:
ShowFieldContentandShowFieldTypeAndContentnow use a slightly different output format. If this causes too much trouble for your test cases, you can get the old behaviour back (mostly) by addingpolymorphic_showfield_old_format = Trueto your model definitions.ShowField...now also produces more informative output for custom primary keys..non_polymorphic()queryset member function added. This is preferable to using.base_objects..., as it just makes the resulting queryset non-polymorphic and does not change anything else in the behaviour of the manager used (while.base_objectsis just a different manager)..get_real_instances(): implementation modified to allow the following more simple and intuitive use:>>> qs = ModelA.objects.all().non_polymorphic() >>> qs.get_real_instances()
which is equivalent to:
>>> ModelA.objects.all()
added member function:
normal_q_object = ModelA.translate_polymorphic_Q_object(enhanced_q_object)misc changes/improvements
Bugfixes¶
Custom fields could cause problems when used as the primary key. In inherited models, Django’s automatic “.pk” field does not always work correctly for such custom fields: “some_object.pk” and “some_object.id” return different results (which they shouldn’t, as pk should always be just an alias for the primary key field). It’s unclear yet if the problem lies in Django or the affected custom fields. Regardless, the problem resulting from this has been fixed with a small workaround. “python manage.py test polymorphic” also tests and reports on this problem now. Thanks to Mathieu Steele for reporting and the test case.
V1.0 Beta 1 (2010-10-18)¶
This release is mostly a cleanup and maintenance release that also improves a number of minor things and fixes one (non-critical) bug.
Some pending API changes and corrections have been folded into this release in order to make the upcoming V1.0 API as stable as possible.
This release is also about getting feedback from you in case you don’t approve of any of these changes or would like to get additional API fixes into V1.0.
The release contains a considerable amount of changes in some of the more critical parts of the software. It’s intended for testing and development environments and not for production environments. For these, it’s best to wait a few weeks for the proper V1.0 release, to allow some time for any potential problems to show up (if they exist).
If you encounter any such problems, please post them in the discussion group or open an issue on GitHub or BitBucket (or send me an email).
There also have been a number of minor API changes. Please see the README for more information.
New Features¶
official Django 1.3 alpha compatibility
PolymorphicModel.__getattribute__hack removed. This improves performance considerably as python’s __getattribute__ generally causes a pretty large processing overhead. It’s gone now.the
polymorphic_dumpdatamanagement command is not needed anymore and has been disabled, as the regular Django dumpdata command now automatically works correctly with polymorphic models (for all supported versions of Django)..get_real_instances()has been elevated to an official part of the API:real_objects = ModelA.objects.get_real_instances(base_objects_list_or_queryset)
allows you to turn a queryset or list of base objects into a list of the real instances. This is useful if e.g. you use
ModelA.base_objects.extra(...)and then want to transform the result to its polymorphic equivalent.translate_polymorphic_Q_object(see DOCS)improved testing
Changelog added: CHANGES.rst/html
Bugfixes¶
Removed requirement for primary key to be an IntegerField. Thanks to Mathieu Steele and Malthe Borch.
API Changes¶
polymorphic_dumpdata
The management command polymorphic_dumpdata is not needed anymore
and has been disabled, as the regular Django dumpdata command now automatically
works correctly with polymorphic models (for all supported versions of Django).
Output of Queryset or Object Printing
In order to improve compatibility with vanilla Django, printing quersets (__repr__ and __unicode__) does not use django_polymorphic’s pretty printing by default anymore. To get the old behaviour when printing querysets, you need to replace your model definition:
>>> class Project(PolymorphicModel):
by:
>>> class Project(PolymorphicModel, ShowFieldType):
The mixin classes for pretty output have been renamed:
ShowFieldTypes, ShowFields, ShowFieldsAndTypes
are now:
ShowFieldType, ShowFieldContent and ShowFieldTypeAndContent
(the old ones still exist for compatibility)
Running the Test suite with Django 1.3
Django 1.3 requires python manage.py test polymorphic instead of
just python manage.py test.
Beta Release (2010-2-22)¶
IMPORTANT: API Changed (import path changed), and Installation Note
The django_polymorphic source code has been restructured and as a result needs to be installed like a normal Django App - either via copying the “polymorphic” directory into your Django project or by running setup.py. Adding ‘polymorphic’ to INSTALLED_APPS in settings.py is still optional, however.
The file polymorphic.py cannot be used as a standalone extension module anymore, as is has been split into a number of smaller files.
Importing works slightly different now: All relevant symbols are imported directly from ‘polymorphic’ instead from ‘polymorphic.models’:
# new way
from polymorphic import PolymorphicModel, ...
# old way, doesn't work anymore
from polymorphic.models import PolymorphicModel, ...
minor API addition: ‘from polymorphic import VERSION, get_version’
New Features¶
Python 2.4 compatibility, contributed by Charles Leifer. Thanks!
Bugfixes¶
Fix: The exception “…has no attribute ‘sub_and_superclass_dict’” could be raised. (This occurred if a subclass defined __init__ and accessed class members before calling the superclass __init__). Thanks to Mattias Brändström.
Fix: There could be name conflicts if field_name == model_name.lower() or similar. Now it is possible to give a field the same name as the class (like with normal Django models). (Found through the example provided by Mattias Brändström)
Beta Release (2010-2-4)¶
New features (and documentation)¶
queryset order_by method added
queryset aggregate() and extra() methods implemented
queryset annotate() method implemented
queryset values(), values_list(), distinct() documented; defer(), only() allowed (but not yet supported)
setup.py added. Thanks to Andrew Ingram.
More about these additions in the docs: http://bserve.webhop.org/wiki/django_polymorphic/doc
Bugfixes¶
fix remaining potential accessor name clashes (but this only works with Django 1.2+, for 1.1 no changes). Thanks to Andrew Ingram.
fix use of ‘id’ model field, replaced with ‘pk’.
fix select_related bug for objects from derived classes (till now sel.-r. was just ignored)
“Restrictions & Caveats” updated¶
Django 1.1 only - the names of polymorphic models must be unique in the whole project, even if they are in two different apps. This results from a restriction in the Django 1.1 “related_name” option (fixed in Django 1.2).
Django 1.1 only - when ContentType is used in models, Django’s seralisation or fixtures cannot be used. This issue seems to be resolved for Django 1.2 (changeset 11863: Fixed #7052, Added support for natural keys in serialization).
Beta Release (2010-1-30)¶
Fixed ContentType related field accessor clash (an error emitted by model validation) by adding related_name to the ContentType ForeignKey. This happened if your polymorphc model used a ContentType ForeignKey. Thanks to Andrew Ingram.
Beta Release (2010-1-29)¶
Restructured django_polymorphic into a regular Django add-on application. This is needed for the management commands, and also seems to be a generally good idea for future enhancements as well (and it makes sure the tests are always included).
The poly app - until now being used for test purposes only
- has been renamed to polymorphic. See DOCS.rst
(“installation/testing”) for more info.
Beta Release (2010-1-28)¶
Added the polymorphic_dumpdata management command (github issue 4), for creating fixtures, this should be used instead of the normal Django dumpdata command. Thanks to Charles Leifer.
Important: Using ContentType together with dumpdata generally needs Django 1.2 (important as any polymorphic model uses ContentType).
Beta Release (2010-1-26)¶
IMPORTANT - database schema change (more info in change log). I hope I got this change in early enough before anyone started to use polymorphic.py in earnest. Sorry for any inconvenience. This should be the final DB schema now.
Django’s ContentType is now used instead of app-label and model-name This is a cleaner and more efficient solution Thanks to Ilya Semenov for the suggestion.