- Added support for Django 4.0.
- Fixed crash when the admin "add type" view has no choices; will show a permission denied.
- Fixed missing
locale
folder in sdist. - Fixed missing
QuerySet.bulk_create(.., ignore_conflicts=True)
parameter support. - Fixed
FilteredRelation
support. - Fixed supporting class keyword arguments in model definitions for
__init_subclass__()
. - Fixed including
polymorphic.tests.migrations
in the sdist. - Fixed non-polymorphic parent handling, which has no
_base_objects
. - Fixed missing
widgets
support formodelform_factory()
. - Fixed
has_changed
handling forpolymorphic_ctype_id
due to implicit str to int conversions. - Fixed
Q
object 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!
- Support for Django 3.X
- Dropped support for python 2.X
- A lot of various fixes and improvements by various authors. Thanks a lot!
- Fix
PolymorphicInlineModelAdmin
media jQuery include for Django 2.0+
- Fixed admin import error due to
isort
changes.
- Added Django 2.2 support.
- Changed
.non_polymorphic()
, to use a different iterable class that completely cirvumvent polymorphic. - Changed SQL for
instance_of
filter: useIN
statement instead ofOR
clauses. - 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
TypeError
exception whenPolymorphicTypeInvalid
should have raised. - Fixed hiding the add-button of polymorphic lines in the Django admin.
- Reformatted all files with black
- Fixed admin crash for Django 2.1 with missing
use_required_attribute
.
- Fixed manager inheritance behavior for Django 1.11, by automatically enabling
Meta.manager_inheritance_from_future
if it's not defined. This restores the manager inheritance behavior that django-polymorphic 1.3 provided for Django 1.x projects. - Fixed internal
base_objects
usage.
Fixed manager inheritance detection for Django 1.11.
It's recommended to use
Meta.manager_inheritance_from_future
so Django 1.x code also inherit thePolymorphicManager
in all subclasses. Django 2.0 already does this by default.Deprecated the
base_objects
manager. Useobjects.non_polymorphic()
instead.Optimized detection for dumpdata behavior, avoiding the performance hit of
__getattribute__()
.Fixed test management commands
- 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
PolymorphicTypeUndefined
exception for incomplete imported models. When a data migration or import creates an polymorphic model, thepolymorphic_ctype_id
field should be filled in manually too. Thepolymorphic.utils.reset_polymorphic_ctype
function can be used for that. - Added
PolymorphicTypeInvalid
exception when database was incorrectly imported. - Added
polymorphic.utils.get_base_polymorphic_model()
to find the base model for types. - Using
base_model
on the polymorphic admins is no longer required, as this can be autodetected. - Fixed manager errors for swappable models.
- Fixed
deleteText
of|as_script_options
template 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_id
is 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_fieldsets
is removed since Django 1.9)
Backported various fixes from 2.x to support older Django versions:
- Added
PolymorphicTypeUndefined
exception for incomplete imported models. When a data migration or import creates an polymorphic model, thepolymorphic_ctype_id
field should be filled in manually too. Thepolymorphic.utils.reset_polymorphic_ctype
function can be used for that. - Added
PolymorphicTypeInvalid
exception when database was incorrectly imported. - Added
polymorphic.utils.get_base_polymorphic_model()
to find the base model for types. - Using
base_model
on the polymorphic admins is no longer required, as this can be autodetected. - Fixed manager errors for swappable models.
- Fixed
deleteText
of|as_script_options
template 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_id
is 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_fieldsets
is removed since Django 1.9)
- 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.
- Django 1.11 support.
- Fixed
PolymorphicInlineModelAdmin
to 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-index
attribute for admin menu appearance.
- 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.
- 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
ParentAdminNotRegistered
exception for models that are registered via a proxy model instead of the real base model.
- Fixed compatibility with manager changes in Django 1.10.1
- 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
PolymorphicChildModelAdmin
with the admin site too. - The
child_models
attribute of thePolymorphicParentModelAdmin
should 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.
- Fix formset empty-form display when there are form errors.
- Fix formset empty-form hiding for Grappelli.
- Fixed packing
admin/polymorphic/edit_inline/stacked.html
in the wheel format.
- Fix error when using
date_hierarchy
field in the admin - Fixed Django 1.10 warning in admin add-type view.
- 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_template
breadcrumb. NOTE: when using django-reversion / django-reversion-compare, make sure to implement aadmin/polymorphic/object_history.html
template in your project that extends fromreversion/object_history.html
orreversion-compare/object_history.html
respectively.
- 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 :ref:`django-reversion-compare support <django-reversion-compare-support>`.
- Fixed support for reverse relations for
relname___field
when the field starts with an_
character. Otherwise, the query will be interpreted as subclass lookup (ClassName___field
).
- Added Django 1.9 compatibility.
- Renamed
polymorphic.manager
=>polymorphic.managers
for 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__.py
in 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)
- Added
queryset.as_manager()
support for Django 1.7/1.8 - Optimize 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
AdminSite
class for the parent object. - Fixed Pickle exception when polymorphic model is cached.
- Fixed Django 1.8 support for related field widgets.
- 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_manager
to 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)
- Remove Django 1.7 warnings
- Fix Django 1.4/1.5 queryset calls on related objects for unknown methods.
The
RelatedManager
code overridesget_query_set()
while__getattr__()
used the new-styleget_queryset()
. - Fix validate_model_fields(), caused errors when metaclass raises errors
- 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.
- Added
pk_regex
to thePolymorphicParentModelAdmin
to support non-integer primary keys. - Fixed passing
?ct_id=
to the add view for Django 1.6 (fixes compatibility with django-parler).
- Fixed
get_real_instance_class()
for proxy models (broke in 0.5.4).
- Fix
.non_polymorphic()
to returns a clone of the queryset, instead of effecting the existing queryset. - Fix missing
alters_data = True
annotations on the overwrittensave()
methods. - Fix infinite recursion bug in the admin with Django 1.6+
- Added detection of bad
ContentType
table data.
- Fix TypeError when
base_form
was not defined. - Fix passing
/admin/app/model/id/XYZ
urls to the correct admin backend. There is no need to include a?ct_id=..
field, as the ID already provides enough information.
- 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__ _underscorefield
instead 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.
- Add Django 1.6 support.
- Fix Grappelli theme support in the "Add type" view.
- Add Python 3.2 and 3.3 support
- Fix errors with ContentType objects that don't refer to an existing model.
- Used proper
__version__
marker.
- Add Django 1.5 and 1.6 support
- Add proxy model support
- Add default admin
list_filter
for polymorphic model type. - Fix queryset support of related objects.
- Performed an overall cleanup of the project
- Deprecated the
queryset_class
argument of thePolymorphicManager
constructor, use the class attribute instead. - Dropped Django 1.1, 1.2 and 1.3 support
- Update example project for Django 1.4
- Added tox and Travis configuration
- SQL optimization, avoid query in pre_save_polymorphic()
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
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.
For a detailed list of it's changes, see the :doc:`archived changelog <changelog_archive>`.