Debian Codegraph @

docs/changelog/index.rst

raw
1 Changelog
2 =========
3
4 v4.11.7 (2026-07-31)
5 --------------------
6
7 * Support Django 6.1
8 * Fixed `Regression: A recent update in the save method removed sending kwargs to the super.save
9 method breaking the save function
10 <https://github.com/django-commons/django-polymorphic/issues/905>`_
11
12
13 v4.11.6 (2026-07-09)
14 --------------------
15
16 * Fixed `Fields deferred by base manager raise KeyError when accessed.
17 <https://github.com/django-commons/django-polymorphic/issues/906>`_
18
19
20 v4.11.5 (2026-05-31)
21 --------------------
22
23 * Fixed `PolymorphicChildModelAdmin redirects to the root model list view instead of the first
24 PolymorphicParentModelAdmin <https://github.com/django-commons/django-polymorphic/issues/863>`_
25
26 - Small admin behavior change: When both the root model and an intermediate subclass have a
27 ``PolymorphicParentModelAdmin`` registered, post-save now redirects to the most-derived
28 (nearest) parent admin rather than the root's.
29
30 v4.11.4 (2026-05-28)
31 --------------------
32
33 * Fixed `pylint issue starting in version 4.11.0: E1111 assignment-from-no-return
34 <https://github.com/django-commons/django-polymorphic/issues/898>`_
35
36
37 v4.11.3 (2026-04-30)
38 --------------------
39
40 * `django-polymorphic <https://github.com/django-commons/django-polymorphic>`_ has a new home at the
41 `django-commons <https://django-commons.org>`_ organization!
42
43 * This was necessary because `Jazzband is sunsetting
44 <https://github.com/jazzband/help/issues/425>`_. Jazzband was a great home that facilitated
45 maintainership transfer of this package. We are extremely thankful for all of `jezdez's
46 <https://github.com/jezdez>`_ work over the years running the Jazzband community.
47 * We limited publishing access to restrict our supply chain vulnerability surface. If you were a
48 former contributor/maintainer of this project and wish to contribute again please `join
49 django-commons <https://github.com/django-commons/membership>`_ and let us know.
50
51
52 v4.11.2 (2026-03-05)
53 --------------------
54
55 * Add typed classifier.
56 * Remove unnecessary :func:`~django.utils.safestring.mark_safe` from `admin context variables
57 <https://github.com/bckohan/django-polymorphic/commit/6c6114d4c72bb6db73eee54ce58beb93409ec137>`_.
58 * Significant security tightening of CI pipelines including security focused static
59 analysis tools: zizmor, CodeQL and bandit.
60
61 v4.11.1 (2026-02-20)
62 --------------------
63
64 * Fixed `Release 4.11 causes UPDATE query to be routed to reader DB <https://github.com/django-commons/django-polymorphic/issues/865>`_
65
66 v4.11.0 (2026-02-05)
67 --------------------
68
69 * Implemented `Add type hints for django-polymorphic <https://github.com/django-commons/django-polymorphic/issues/647>`_
70
71 v4.9.2, v4.10.5 (2026-01-26)
72 ----------------------------
73
74 * Fixed `Bad warning messages polymorphic.W001 and polymorphic.W002 when deriving from PolymorphicModel <https://github.com/django-commons/django-polymorphic/issues/857>`_
75 * Fixed `Unexpected return type of polymorphic data since 4.9.1 <https://github.com/django-commons/django-polymorphic/issues/855>`_
76 * Fixed `related item missing <https://github.com/django-commons/django-polymorphic/issues/851>`_
77
78 v4.10.4 (2026-01-19)
79 --------------------
80
81 * Documented `model-bakery integration and test considerations <https://github.com/django-commons/django-polymorphic/issues/849>`_
82
83 v4.9.1, v4.10.3 (2026-01-15)
84 ----------------------------
85
86 * Fixed `Meta.base_manager_name is not respected <https://github.com/django-commons/django-polymorphic/issues/845>`_
87
88
89 v4.10.2 (2026-01-14)
90 --------------------
91
92 * Fixed `changelog url on pypi is broken <https://github.com/django-commons/django-polymorphic/issues/842>`_
93
94 v4.10.1 (2026-01-13)
95 --------------------
96
97 * Fixed `Django-polymorphic does not update the PolymorphicSerializer's validated_data after running the child's validation method <https://github.com/django-commons/django-polymorphic/pull/378>`_
98
99 v4.10.0 (2026-01-13)
100 --------------------
101
102 This release is primarily an integrations release. Many tests were added for the documented
103 intergrations and a few bugs were fixed. Some warnings were converted to system checks. The two most
104 notable changes are:
105
106 1. The :pypi:`django-rest-polymorphic` package is now part of :pypi:`django-polymorphic`.
107 2. In queries that need content types that are not cached those fetches are `now embedded as
108 subqueries <https://github.com/django-commons/django-polymorphic/pull/828>`_. This reduces the total
109 number of queries needed but most importantly it eliminates `a class of errors
110 <https://github.com/django-commons/django-polymorphic/issues/383>`_ that could happen if
111 Manager/QuerySet methods that should not but do generate database queries are called before
112 models are loaded (e.g. get_queryset()).
113
114 Issues
115 ~~~~~~
116
117 * Implemented `Bring django-rest-polymorphic into this package. <https://github.com/django-commons/django-polymorphic/issues/655>`_
118
119 .. tip::
120
121 :pypi:`django-rest-polymorphic` is now part of :pypi:`django-polymorphic`. You must update
122 your import paths from ``rest_polymorphic.serializers`` to
123 :mod:`polymorphic.contrib.drf.serializers`.
124
125 * Fixed `Guardian contenttype integraton hook is extremely brittle <https://github.com/django-commons/django-polymorphic/issues/836>`_
126 * Fixed `Models defined after load break inheritance utility caches <https://github.com/django-commons/django-polymorphic/issues/827>`_
127 * Fixed `get_queryset() results in db queries for proxy models <https://github.com/django-commons/django-polymorphic/issues/824>`_
128 * Implemented `System check error for PolymorphicManager marked as use_in_migrations <https://github.com/django-commons/django-polymorphic/issues/820>`_
129 * Implemented `Manager warnings should be system checks instead. <https://github.com/django-commons/django-polymorphic/issues/819>`_
130
131 v4.9.0 (2026-01-09)
132 -------------------
133
134 .. note::
135
136 This update may generate new migrations for your polymorphic models, similar to the following.
137 This is ok and an expected side effect of fixing `#815
138 <https://github.com/django-commons/django-polymorphic/issues/815>`_
139
140 .. code-block:: python
141
142 migrations.AlterModelOptions(
143 name='modelname',
144 options={},
145 )
146
147 * Fixed `PolymorphicModel.base_manager is the same as default_manager when custom default manager is supplied. <https://github.com/django-commons/django-polymorphic/issues/815>`_
148 * Fixed `Use non-polymorphic managers for all invocations of dumpdata <https://github.com/django-commons/django-polymorphic/pull/814>`_
149 * Documented `Fixture usage <https://github.com/django-commons/django-polymorphic/pull/791>`_
150
151 v4.8.0 (2026-01-08)
152 -------------------
153
154 * Fixed `PolymorphicFormSetChild overrides form exclude <https://github.com/django-commons/django-polymorphic/issues/578>`_
155 * Fixed `Issue with polymorphic_ctype when populating polymorphic inline formsets. <https://github.com/django-commons/django-polymorphic/issues/549>`_
156 * Fixed `Nested polymorphic_inline_formsets gives AttributeError: 'NoneType' object has no attribute 'get_real_instance_class' <https://github.com/django-commons/django-polymorphic/issues/363>`_
157
158 v4.7.0 (2026-01-07)
159 -------------------
160
161 Fixed a few outstanding admin bugs, updated documentation and added more admin tests for things like
162 m2m relationships.
163
164 * Documented `How to handle non-admin polymorphic forms? <https://github.com/django-commons/django-polymorphic/issues/346>`_
165 * Fixed `Admin: add view popup breaks if initial submit has validation error <https://github.com/django-commons/django-polymorphic/issues/612>`_
166 * Fixed `Filters are not preserved in polymorphic parent admin <https://github.com/django-commons/django-polymorphic/issues/356>`_
167 * Fixed `Admin change form doesn't preserve changelist filter <https://github.com/django-commons/django-polymorphic/issues/125>`_
168
169 v4.6.0 (2026-01-05)
170 -------------------
171
172 The release fixes longstanding bugs with respect to expected ORM behavior. For a complete list of
173 changes see the `v4.6.0 release
174 <https://github.com/django-commons/django-polymorphic/releases/tag/v4.6.0>`_.
175
176 * Fixed `get_real_instance() should also gracefully retry parents on failure (best effort) <https://github.com/django-commons/django-polymorphic/issues/784>`_
177 * Fixed `polymorphic_primary_key_name no longer points to base classes polymorphic field <https://github.com/django-commons/django-polymorphic/issues/758>`_
178 * Fixed `create_from_super needs to run atomically. <https://github.com/django-commons/django-polymorphic/issues/744>`_
179 * Fixed `Support polymorphic models that have different pk fields/values at different levels of the hierarchy. <https://github.com/django-commons/django-polymorphic/issues/686>`_
180 * Fixed `Issue with .delete(keep_parents=True) <https://github.com/django-commons/django-polymorphic/issues/645>`_
181 * Fixed `PolymorphicChildModelAdmin with show_in_index=False in Django Admin with nav_sidebar <https://github.com/django-commons/django-polymorphic/issues/497>`_
182 * Fixed `ForeignKeyViolation when trying to save an entity when using a non-default db <https://github.com/django-commons/django-polymorphic/issues/486>`_
183 * Fixed `Content types pulled from wrong database when using database routers <https://github.com/django-commons/django-polymorphic/issues/446>`_
184 * Fixed `Copying Polymorphic objects for below the first level not working <https://github.com/django-commons/django-polymorphic/issues/414>`_
185 * Fixed `Getting a specific element from a queryset in an post_delete returns None <https://github.com/django-commons/django-polymorphic/issues/347>`_
186 * Fixed `Reverse related object descriptor is overwritten on class <https://github.com/django-commons/django-polymorphic/issues/71>`_
187
188 v4.3.1, v4.4.2, v4.5.2 (2026-01-01)
189 -----------------------------------
190
191 * Fixed `Significant performance regression on polymorphic queryset iteration <https://github.com/django-commons/django-polymorphic/pull/781>`_
192
193 v4.5.1 (2025-12-24)
194 -------------------
195
196 * Fixed `4.5.0 generates a lot of migrations on my project <https://github.com/django-commons/django-polymorphic/pull/759>`_
197 * Fixed `Annotations with F <https://github.com/django-commons/django-polymorphic/pull/755>`_
198 * Fixed `show_in_index=False visibility in admin sites and sidebar <https://github.com/django-commons/django-polymorphic/pull/760>`_
199
200 v4.5.0 (2025-12-22)
201 -------------------
202
203 The release fixes longstanding bugs with respect to deletion of polymorphic models.
204
205 .. warning::
206
207 This version has a bug that generates unnecessary migrations - use 4.5.1 instead!
208
209 * Implemented `Deletion fixes <https://github.com/django-commons/django-polymorphic/pull/746>`_
210 **This release fixes the longstanding polymorphic deletion bug.** The fix should be transparent
211 and not generate new migrations files. If you experience any issues, please report them.
212 * Fixed `AttributeError Using .alias() On Polymorphic Querysets <https://github.com/django-commons/django-polymorphic/pull/745>`_
213
214 v4.4.1 (2025-12-15)
215 -------------------
216
217 * `Fix infinite recursion bug when using only() <https://github.com/django-commons/django-polymorphic/pull/739>`_
218
219 v4.4.0 (2025-12-14)
220 -------------------
221
222 * Implemented `Add create_from_super method and test <https://github.com/django-commons/django-polymorphic/pull/684>`_
223 * Implemented `Move model definition errors to system checks <https://github.com/django-commons/django-polymorphic/pull/693>`_
224 * Fixed `Fix ordering of stacked inline admin forms on add. <https://github.com/django-commons/django-polymorphic/pull/719>`_
225 * Fixed `Change model definition errors to be system checks <https://github.com/django-commons/django-polymorphic/pull/693>`_
226 * Fixed `Replace deepcopy of the Q object <https://github.com/django-commons/django-polymorphic/pull/543>`_
227
228 v4.3.0 (2025-12-09)
229 -------------------
230
231 * Fixed `Resolve primary key name correctly. <https://github.com/django-commons/django-polymorphic/pull/620>`_
232 * Implemented `Include get_child_inlines() hook in stacked inline admin forms. <https://github.com/django-commons/django-polymorphic/pull/681>`_
233 * Fixed `multi-database support in inheritance accessors. <https://github.com/django-commons/django-polymorphic/pull/550>`_
234 * Fixed `Caching in inheritance accessor functions <https://github.com/django-commons/django-polymorphic/pull/510>`_
235 * Fixed `Foreign key resolves to parent class when using abstract models <https://github.com/django-commons/django-polymorphic/issues/437>`_
236 * Fixed `Support Q expressions that contain subquery expressions <https://github.com/django-commons/django-polymorphic/pull/572>`_
237
238 v4.2.0 (2025-12-04)
239 -------------------
240
241 * Fixed `The objects which were transmogrified aren't initialized correctly if they implement __init__ method. <https://github.com/django-commons/django-polymorphic/issues/615>`_
242 * Implemented `Defer to chunk_size parameter on .iterators for fetching get_real_instances() <https://github.com/django-commons/django-polymorphic/pull/672>`_
243 * Fixed `Show full admin context (breadcrumb and logout nav) in model type selection admin form <https://github.com/django-commons/django-polymorphic/pull/580>`_
244 * Fixed `Issue with Autocomplete Fields in StackedPolymorphicInline.Child Inline <https://github.com/django-commons/django-polymorphic/issues/546>`_
245 * 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.
246 * `Modernized package management with new build, test, docs tooling and improved CI
247 <https://github.com/django-commons/django-polymorphic/issues/651>`_.
248
249 v4.1.0 (2025-05-20)
250 -------------------
251
252 * `Fixed a bug on Django 5 <https://github.com/django-commons/django-polymorphic/pull/621>`_ where
253 `aggregation queries could result in None-type errors <https://github.com/django-commons/django-polymorphic/issues/616>`_
254 * `Use css variables in the admin css <https://github.com/django-commons/django-polymorphic/pull/622>`_
255
256 v4.0.0 (2025-05-20)
257 -------------------
258
259 **There were no breaking changes in this major release**
260
261 *This was the first release under* `Jazzband <https://jazzband.co/>`_.
262
263 There were many updates modernizing the package and incorporating Jazzband standards:
264
265 * Updates to documentation
266 * Formatting and linting with ruff
267 * Moving to GHA from Travis CI
268 * Switch to pytest
269
270 Changes that touched the core package code were:
271
272 * Remove `legacy Django/python version checks <https://github.com/django-commons/django-polymorphic/pull/567>`_
273 * Replace `string formats with f-strings <https://github.com/django-commons/django-polymorphic/pull/566>`_
274 * Removed `deprecated usage of package_resources <https://github.com/django-commons/django-polymorphic/pull/541>`_
275 - as of Python 3.12 package_resources was removed. To get prior releases to work on >3.12 you
276 would also need to install `setuptools <https://pypi.org/project/setuptools/>`_.
277 * Fixed `multi field lines do not render in the admin <https://github.com/django-commons/django-polymorphic/pull/539>`_
278 * Fixed `dark mode rendering in the polymorphic admin <https://github.com/django-commons/django-polymorphic/pull/508>`_
279
280 v3.1.0 (2021-11-18)
281 -------------------
282
283 * Added support for Django 4.0.
284 * Fixed crash when the admin "add type" view has no choices; will show a permission denied.
285 * Fixed missing ``locale`` folder in sdist.
286 * Fixed missing ``QuerySet.bulk_create(.., ignore_conflicts=True)`` parameter support.
287 * Fixed ``FilteredRelation`` support.
288 * Fixed supporting class keyword arguments in model definitions for ``__init_subclass__()``.
289 * Fixed including ``polymorphic.tests.migrations`` in the sdist.
290 * Fixed non-polymorphic parent handling, which has no ``_base_objects``.
291 * Fixed missing ``widgets`` support for ``modelform_factory()``.
292 * Fixed ``has_changed`` handling for ``polymorphic_ctype_id`` due to implicit str to int
293 conversions.
294 * Fixed ``Q`` object handling when lists are used (e.g. in django-advanced-filters_).
295 * Fixed Django Admin support when using a script-prefix.
296
297 Many thanks to everyone providing clear pull requests!
298
299
300 v3.0.0 (2020-08-21)
301 -------------------
302
303 * Support for Django 3.X
304 * Dropped support for python 2.X
305 * A lot of various fixes and improvements by various authors. Thanks a lot!
306
307
308 v2.1.2 (2019-07-15)
309 -------------------
310
311 * Fix ``PolymorphicInlineModelAdmin`` media jQuery include for Django 2.0+
312
313
314 v2.1.1 (2019-07-15)
315 -------------------
316
317 * Fixed admin import error due to ``isort`` changes.
318
319
320 v2.1 (2019-07-15)
321 -----------------
322
323 * Added Django 2.2 support.
324 * Changed ``.non_polymorphic()``, to use a different iterable class that completely circumvent
325 polymorphic.
326 * Changed SQL for ``instance_of`` filter: use ``IN`` statement instead of ``OR`` clauses.
327 * Changed queryset iteration to implement ``prefetch_related()`` support.
328 * Fixed Django 3.0 alpha compatibility.
329 * Fixed compatibility with current django-extra-views_ in ``polymorphic.contrib.extra_views``.
330 * Fixed ``prefetch_related()`` support on polymorphic M2M relations.
331 * Fixed model subclass ``___`` selector for abstract/proxy models.
332 * Fixed model subclass ``___`` selector for models with a custom
333 ``OneToOneField(parent_link=True)``.
334 * Fixed unwanted results on calling ``queryset.get_real_instances([])``.
335 * Fixed unwanted ``TypeError`` exception when ``PolymorphicTypeInvalid`` should have raised.
336 * Fixed hiding the add-button of polymorphic lines in the Django admin.
337 * Reformatted all files with black
338
339
340 v2.0.3 (2018-08-24)
341 -------------------
342
343 * Fixed admin crash for Django 2.1 with missing ``use_required_attribute``.
344
345
346 v2.0.2 (2018-02-05)
347 -------------------
348
349 * Fixed manager inheritance behavior for Django 1.11, by automatically enabling
350 ``Meta.manager_inheritance_from_future`` if it's not defined. This restores the manager
351 inheritance behavior that *django-polymorphic 1.3* provided for Django 1.x projects.
352 * Fixed internal ``base_objects`` usage.
353
354
355 v2.0.1 (2018-02-05)
356 -------------------
357
358 * Fixed manager inheritance detection for Django 1.11.
359
360 It's recommended to use ``Meta.manager_inheritance_from_future`` so Django 1.x code also inherit
361 the ``PolymorphicManager`` in all subclasses. Django 2.0 already does this by default.
362
363 * Deprecated the ``base_objects`` manager. Use ``objects.non_polymorphic()`` instead.
364 * Optimized detection for dumpdata behavior, avoiding the performance hit of ``__getattribute__()``.
365 * Fixed test management commands
366
367
368 v2.0.0 (2018-01-22)
369 -------------------
370
371 * **BACKWARDS INCOMPATIBILITY:** Dropped Django 1.8 and 1.10 support.
372 * **BACKWARDS INCOMPATIBILITY:** Removed old deprecated code from 1.0, thus:
373
374 * Import managers from ``polymorphic.managers`` (plural), not ``polymorphic.manager``.
375 * Register child models to the admin as well using ``@admin.register()`` or
376 ``admin.site.register()``, as this is no longer done automatically.
377
378 * Added Django 2.0 support.
379
380 Also backported into 1.3.1:
381
382 * Added ``PolymorphicTypeUndefined`` exception for incomplete imported models.
383 When a data migration or import creates an polymorphic model,
384 the ``polymorphic_ctype_id`` field should be filled in manually too.
385 The ``polymorphic.utils.reset_polymorphic_ctype`` function can be used for that.
386 * Added ``PolymorphicTypeInvalid`` exception when database was incorrectly imported.
387 * Added ``polymorphic.utils.get_base_polymorphic_model()`` to find the base model for types.
388 * Using ``base_model`` on the polymorphic admins is no longer required, as this can be autodetected.
389 * Fixed manager errors for swappable models.
390 * Fixed ``deleteText`` of ``|as_script_options`` template filter.
391 * Fixed ``.filter(applabel__ModelName___field=...)`` lookups.
392 * Fixed proxy model support in formsets.
393 * Fixed error with .defer and child models that use the same parent.
394 * Fixed error message when ``polymorphic_ctype_id`` is null.
395 * Fixed fieldsets recursion in the admin.
396 * Improved ``polymorphic.utils.reset_polymorphic_ctype()`` to accept models in random ordering.
397 * Fix fieldsets handling in the admin (``declared_fieldsets`` is removed since Django 1.9)
398
399
400 v1.3.1 (2018-04-16)
401 -------------------
402
403 Backported various fixes from 2.x to support older Django versions:
404
405 * Added ``PolymorphicTypeUndefined`` exception for incomplete imported models.
406 When a data migration or import creates an polymorphic model,
407 the ``polymorphic_ctype_id`` field should be filled in manually too.
408 The ``polymorphic.utils.reset_polymorphic_ctype`` function can be used for that.
409 * Added ``PolymorphicTypeInvalid`` exception when database was incorrectly imported.
410 * Added ``polymorphic.utils.get_base_polymorphic_model()`` to find the base model for types.
411 * Using ``base_model`` on the polymorphic admins is no longer required, as this can be autodetected.
412 * Fixed manager errors for swappable models.
413 * Fixed ``deleteText`` of ``|as_script_options`` template filter.
414 * Fixed ``.filter(applabel__ModelName___field=...)`` lookups.
415 * Fixed proxy model support in formsets.
416 * Fixed error with .defer and child models that use the same parent.
417 * Fixed error message when ``polymorphic_ctype_id`` is null.
418 * Fixed fieldsets recursion in the admin.
419 * Improved ``polymorphic.utils.reset_polymorphic_ctype()`` to accept models in random ordering.
420 * Fix fieldsets handling in the admin (``declared_fieldsets`` is removed since Django 1.9)
421
422
423 v1.3.0 (2017-08-01)
424 -------------------
425
426 * **BACKWARDS INCOMPATIBILITY:** Dropped Django 1.4, 1.5, 1.6, 1.7, 1.9 and Python 2.6 support.
427 Only official Django releases (1.8, 1.10, 1.11) are supported now.
428 * Allow expressions to pass unchanged in ``.order_by()``
429 * Fixed Django 1.11 accessor checks (to support subclasses of ``ForwardManyToOneDescriptor``, like
430 ``ForwardOneToOneDescriptor``)
431 * Fixed polib syntax error messages in translations.
432
433
434 v1.2.0 (2017-05-01)
435 -------------------
436
437 * Django 1.11 support.
438 * Fixed ``PolymorphicInlineModelAdmin`` to explictly exclude ``polymorphic_ctype``.
439 * Fixed Python 3 TypeError in the admin when preserving the query string.
440 * Fixed Python 3 issue due to ``force_unicode()`` usage instead of ``force_text()``.
441 * Fixed ``z-index`` attribute for admin menu appearance.
442
443
444 v1.1.0 (2017-02-03)
445 -------------------
446
447 * Added class based formset views in ``polymorphic/contrib/extra_views``.
448 * Added helper function ``polymorphic.utils.reset_polymorphic_ctype()``.
449 This eases the migration old existing models to polymorphic.
450 * Fixed Python 2.6 issue.
451 * Fixed Django 1.6 support.
452
453
454 v1.0.2 (2016-10-14)
455 -------------------
456
457 * Added helper function for django-guardian_; add
458 ``GUARDIAN_GET_CONTENT_TYPE = 'polymorphic.contrib.guardian.get_polymorphic_base_content_type'``
459 to the project settings to let guardian handles inherited models properly.
460 * Fixed ``polymorphic_modelformset_factory()`` usage.
461 * Fixed Python 3 bug for inline formsets.
462 * Fixed CSS for Grappelli, so model choice menu properly overlaps.
463 * Fixed ``ParentAdminNotRegistered`` exception for models that are registered via a proxy model
464 instead of the real base model.
465
466
467 v1.0.1 (2016-09-11)
468 -------------------
469
470 * Fixed compatibility with manager changes in Django 1.10.1
471
472
473 v1.0.0 (2016-09-02)
474 -------------------
475
476 * Added Django 1.10 support.
477 * Added **admin inline** support for polymorphic models.
478 * Added **formset** support for polymorphic models.
479 * Added support for polymorphic queryset limiting effects on *proxy models*.
480 * Added support for multiple databases with the ``.using()`` method and ``using=..`` keyword
481 argument.
482 * Fixed modifying passed ``Q()`` objects in place.
483
484 .. note::
485 This version provides a new method for registering the admin models.
486 While the old method is still supported, we recommend to upgrade your code.
487 The new registration style improves the compatibility in the Django admin.
488
489 * Register each ``PolymorphicChildModelAdmin`` with the admin site too.
490 * The ``child_models`` attribute of the ``PolymorphicParentModelAdmin`` should be a flat list of
491 all child models. The ``(model, admin)`` tuple is obsolete.
492
493 Also note that proxy models will now limit the queryset too.
494
495
496 Fixed since 1.0b1 (2016-08-10)
497 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
498
499 * Fix formset empty-form display when there are form errors.
500 * Fix formset empty-form hiding for Grappelli_.
501 * Fixed packing ``admin/polymorphic/edit_inline/stacked.html`` in the wheel format.
502
503
504 v0.9.2 (2016-05-04)
505 -------------------
506
507 * Fix error when using ``date_hierarchy`` field in the admin
508 * Fixed Django 1.10 warning in admin add-type view.
509
510
511 v0.9.1 (2016-02-18)
512 -------------------
513
514 * Fixed support for ``PolymorphicManager.from_queryset()`` for custom query sets.
515 * Fixed Django 1.7 ``changeform_view()`` redirection to the child admin site. This fixes custom
516 admin code that uses these views, such as django-reversion_'s ``revision_view()`` /
517 ``recover_view()``.
518 * Fixed ``.only('pk')`` field support.
519 * Fixed ``object_history_template`` breadcrumb.
520 **NOTE:** when using django-reversion_ / django-reversion-compare_, make sure to implement
521 a ``admin/polymorphic/object_history.html`` template in your project that extends
522 from ``reversion/object_history.html`` or ``reversion-compare/object_history.html`` respectively.
523
524
525 v0.9.0 (2016-02-17)
526 -------------------
527
528 * Added ``.only()`` and ``.defer()`` support.
529 * Added support for Django 1.8 complex expressions in ``.annotate()`` / ``.aggregate()``.
530 * Fix Django 1.9 handling of custom URLs.
531 The new change-URL redirect overlapped any custom URLs defined in the child admin.
532 * Fix Django 1.9 support in the admin.
533 * Fix setting an extra custom manager without overriding the ``_default_manager``.
534 * Fix missing ``history_view()`` redirection to the child admin, which is important for
535 django-reversion_ support. See the documentation for hints for
536 `django-reversion-compare support <https://github.com/django-commons/django-polymorphic/discussions/831>_`.
537
538
539 v0.8.1 (2015-12-29)
540 -------------------
541
542 * Fixed support for reverse relations for ``relname___field`` when the field starts with an ``_``
543 character. Otherwise, the query will be interpreted as subclass lookup (``ClassName___field``).
544
545
546 v0.8.0 (2015-12-28)
547 -------------------
548
549 * Added Django 1.9 compatibility.
550 * Renamed ``polymorphic.manager`` => ``polymorphic.managers`` for consistentcy.
551 * **BACKWARDS INCOMPATIBILITY:** The import paths have changed to support Django 1.9.
552 Instead of ``from polymorphic import X``,
553 you'll have to import from the proper package. For example:
554
555 .. code-block:: python
556
557 from polymorphic.models import PolymorphicModel
558 from polymorphic.managers import PolymorphicManager, PolymorphicQuerySet
559 from polymorphic.showfields import ShowFieldContent, ShowFieldType, ShowFieldTypeAndContent
560
561 * **BACKWARDS INCOMPATIBILITY:** Removed ``__version__.py`` in favor of a standard ``__version__``
562 in ``polymorphic/__init__.py``.
563 * **BACKWARDS INCOMPATIBILITY:** Removed automatic proxying of method calls to the queryset class.
564 Use the standard Django methods instead:
565
566 .. code-block:: python
567
568 # In model code:
569 objects = PolymorphicQuerySet.as_manager()
570
571 # For manager code:
572 MyCustomManager = PolymorphicManager.from_queryset(MyCustomQuerySet)
573
574
575
576 v0.7.2 (2015-10-01)
577 -------------------
578
579 * Added ``queryset.as_manager()`` support for Django 1.7/1.8
580 * Optimize model access for non-dumpdata usage; avoid ``__getattribute__()`` call each time to
581 access the manager.
582 * Fixed 500 error when using invalid PK's in the admin URL, return 404 instead.
583 * Fixed possible issues when using an custom ``AdminSite`` class for the parent object.
584 * Fixed Pickle exception when polymorphic model is cached.
585
586
587 v0.7.1 (2015-04-30)
588 -------------------
589
590 * Fixed Django 1.8 support for related field widgets.
591
592
593 v0.7.0 (2015-04-08)
594 -------------------
595
596 * Added Django 1.8 support
597 * Added support for custom primary key defined using
598 ``mybase_ptr = models.OneToOneField(BaseClass, parent_link=True, related_name="...")``.
599 * Fixed Python 3 issue in the admin
600 * Fixed ``_default_manager`` to be consistent with Django, it's now assigned directly instead of
601 using ``add_to_class()``
602 * Fixed 500 error for admin URLs without a '/', e.g. ``admin/app/parentmodel/id``.
603 * Fixed preserved filter for Django admin in delete views
604 * Removed test noise for diamond inheritance problem (which Django 1.7 detects)
605
606
607 v0.6.1 (2014-12-30)
608 -------------------
609
610 * Remove Django 1.7 warnings
611 * Fix Django 1.4/1.5 queryset calls on related objects for unknown methods. The ``RelatedManager``
612 code overrides ``get_query_set()`` while ``__getattr__()`` used the new-style ``get_queryset()``.
613 * Fix validate_model_fields(), caused errors when metaclass raises errors
614
615
616 v0.6.0 (2014-10-14)
617 -------------------
618
619 * Added Django 1.7 support.
620 * Added permission check for all child types.
621 * **BACKWARDS INCOMPATIBILITY:** the ``get_child_type_choices()`` method receives 2 arguments now
622 (request, action). If you have overwritten this method in your code, make sure the method
623 signature is updated accordingly.
624
625
626 v0.5.6 (2014-07-21)
627 -------------------
628
629 * Added ``pk_regex`` to the ``PolymorphicParentModelAdmin`` to support non-integer primary keys.
630 * Fixed passing ``?ct_id=`` to the add view for Django 1.6 (fixes compatibility with
631 django-parler_).
632
633
634 v0.5.5 (2014-04-29)
635 -------------------
636
637 * Fixed ``get_real_instance_class()`` for proxy models (broke in 0.5.4).
638
639
640 v0.5.4 (2014-04-09)
641 -------------------
642
643 * Fix ``.non_polymorphic()`` to returns a clone of the queryset, instead of effecting the existing
644 queryset.
645 * Fix missing ``alters_data = True`` annotations on the overwritten ``save()`` methods.
646 * Fix infinite recursion bug in the admin with Django 1.6+
647 * Added detection of bad ``ContentType`` table data.
648
649
650 v0.5.3 (2013-09-17)
651 -------------------
652
653 * Fix TypeError when ``base_form`` was not defined.
654 * Fix passing ``/admin/app/model/id/XYZ`` urls to the correct admin backend.
655 There is no need to include a ``?ct_id=..`` field, as the ID already provides enough information.
656
657
658 v0.5.2 (2013-09-05)
659 -------------------
660
661 * Fix Grappelli_ breadcrumb support in the views.
662 * Fix unwanted ``___`` handling in the ORM when a field name starts with an underscore;
663 this detects you meant ``relatedfield__ _underscorefield`` instead of ``ClassName___field``.
664 * Fix missing permission check in the "add type" view. This was caught however in the next step.
665 * Fix admin validation errors related to additional non-model form fields.
666
667
668 v0.5.1 (2013-07-05)
669 -------------------
670
671 * Add Django 1.6 support.
672 * Fix Grappelli_ theme support in the "Add type" view.
673
674
675 v0.5.0 (2013-04-20)
676 -------------------
677
678 * Add Python 3.2 and 3.3 support
679 * Fix errors with ContentType objects that don't refer to an existing model.
680
681
682 v0.4.2 (2013-04-10)
683 -------------------
684
685 * Used proper ``__version__`` marker.
686
687
688 v0.4.1 (2013-04-10)
689 -------------------
690
691 * Add Django 1.5 and 1.6 support
692 * Add proxy model support
693 * Add default admin ``list_filter`` for polymorphic model type.
694 * Fix queryset support of related objects.
695 * Performed an overall cleanup of the project
696 * **Deprecated** the ``queryset_class`` argument of the ``PolymorphicManager`` constructor, use the
697 class attribute instead.
698 * **Dropped** Django 1.1, 1.2 and 1.3 support
699
700
701 v0.4.0 (2013-03-25)
702 -------------------
703
704 * Update example project for Django 1.4
705 * Added tox and Travis configuration
706
707
708 v0.3.1 (2013-02-28)
709 -------------------
710
711 * SQL optimization, avoid query in pre_save_polymorphic()
712
713
714 v0.3.0 (2013-02-28)
715 -------------------
716
717 Many changes to the codebase happened, but no new version was released to pypi for years.
718 0.3 contains fixes submitted by many contributors, huge thanks to everyone!
719
720 * Added a polymorphic admin interface.
721 * PEP8 and code cleanups by various authors
722
723
724 v0.2.0 (2011-04-27)
725 -------------------
726
727 The 0.2 release serves as legacy release.
728 It supports Django 1.1 up till 1.4 and Python 2.4 up till 2.7.
729
730 .. _Grappelli: http://grappelliproject.com/
731 .. _django-advanced-filters: https://github.com/modlinltd/django-advanced-filters
732 .. _django-extra-views: https://github.com/AndrewIngram/django-extra-views
733 .. _django-guardian: https://github.com/django-guardian/django-guardian
734 .. _django-parler: https://github.com/django-parler/django-parler
735 .. _django-reversion: https://github.com/etianen/django-reversion
736 .. _django-reversion-compare: https://github.com/jedie/django-reversion-compare
737
738
739 V1.0 Release Candidate 1 (2011-01-24)
740 -------------------------------------
741
742 * Fixed GitHub issue 15 (query result incomplete with inheritance).
743 Thanks to John Debs for reporting and the test case.
744
745
746 Renaming, refactoring, new maintainer (2011-12-20)
747 --------------------------------------------------
748
749 Since the original author disappeared from the internet, we undertook to
750 maintain and upgrade this piece of software.
751
752 The latest "legacy" tag should be V1.0-RC-1. Anything above that should be
753 considered experimental and unstable until further notice (there be dragons).
754
755 New features, bug fixes and other improvements will be added to trunk from now on.
756
757
758 V1.0 Beta 2 (2010-11-11)
759 ------------------------
760
761 Beta 2 accumulated somewhat more changes than intended, and also
762 has been delayed by DBMS benchmark testing I wanted to do on model
763 inheritance. These benchmarks show that there are considerable
764 problems with concrete model inheritance and contemporary DBM systems.
765 The results will be forthcoming on the google discussion forum.
766
767 Please also see: http://www.jacobian.org/writing/concrete-inheritance/
768
769 The API should be stable now with Beta 2, so it's just about potential
770 bugfixes from now on regarding V1.0.
771
772 Beta 2 is still intended for testing and development environments and not
773 for production. No complaints have been heard regarding Beta 1 however,
774 and Beta 1 is used on a few production sites by some enterprising users.
775
776 There will be a release candidate for V1.0 in the very near future.
777
778 New Features and changes
779 ~~~~~~~~~~~~~~~~~~~~~~~~
780
781 * API CHANGE: ``.extra()`` has been re-implemented. Now it's polymorphic by
782 default and works (nearly) without restrictions (please see docs). This is a (very)
783 incompatible API change regarding previous versions of django_polymorphic.
784 Support for the ``polymorphic`` keyword parameter has been removed.
785 You can get back the non-polymorphic behaviour by using
786 ``ModelA.objects.non_polymorphic().extra(...)``.
787
788 * API CHANGE: ``ShowFieldContent`` and ``ShowFieldTypeAndContent`` now
789 use a slightly different output format. If this causes too much trouble for
790 your test cases, you can get the old behaviour back (mostly) by adding
791 ``polymorphic_showfield_old_format = True`` to your model definitions.
792 ``ShowField...`` now also produces more informative output for custom
793 primary keys.
794
795 * ``.non_polymorphic()`` queryset member function added. This is preferable to
796 using ``.base_objects...``, as it just makes the resulting queryset non-polymorphic
797 and does not change anything else in the behaviour of the manager used (while
798 ``.base_objects`` is just a different manager).
799
800 * ``.get_real_instances()``: implementation modified to allow the following
801 more simple and intuitive use::
802
803 >>> qs = ModelA.objects.all().non_polymorphic()
804 >>> qs.get_real_instances()
805
806 which is equivalent to::
807
808 >>> ModelA.objects.all()
809
810 * added member function:
811 ``normal_q_object = ModelA.translate_polymorphic_Q_object(enhanced_q_object)``
812
813 * misc changes/improvements
814
815 Bugfixes
816 ~~~~~~~~
817
818 * Custom fields could cause problems when used as the primary key.
819 In inherited models, Django's automatic ".pk" field does not always work
820 correctly for such custom fields: "some_object.pk" and "some_object.id"
821 return different results (which they shouldn't, as pk should always be just
822 an alias for the primary key field). It's unclear yet if the problem lies in
823 Django or the affected custom fields. Regardless, the problem resulting
824 from this has been fixed with a small workaround.
825 "python manage.py test polymorphic" also tests and reports on this problem now.
826 Thanks to Mathieu Steele for reporting and the test case.
827
828 V1.0 Beta 1 (2010-10-18)
829 ------------------------
830
831 This release is mostly a cleanup and maintenance release that also
832 improves a number of minor things and fixes one (non-critical) bug.
833
834 Some pending API changes and corrections have been folded into this release
835 in order to make the upcoming V1.0 API as stable as possible.
836
837 This release is also about getting feedback from you in case you don't
838 approve of any of these changes or would like to get additional
839 API fixes into V1.0.
840
841 The release contains a considerable amount of changes in some of the more
842 critical parts of the software. It's intended for testing and development
843 environments and not for production environments. For these, it's best to
844 wait a few weeks for the proper V1.0 release, to allow some time for any
845 potential problems to show up (if they exist).
846
847 If you encounter any such problems, please post them in the discussion group
848 or open an issue on GitHub or BitBucket (or send me an email).
849
850 There also have been a number of minor API changes.
851 Please see the README for more information.
852
853 New Features
854 ~~~~~~~~~~~~
855
856 * official Django 1.3 alpha compatibility
857
858 * ``PolymorphicModel.__getattribute__`` hack removed.
859 This improves performance considerably as python's __getattribute__
860 generally causes a pretty large processing overhead. It's gone now.
861
862 * the ``polymorphic_dumpdata`` management command is not needed anymore
863 and has been disabled, as the regular Django dumpdata command now automatically
864 works correctly with polymorphic models (for all supported versions of Django).
865
866 * ``.get_real_instances()`` has been elevated to an official part of the API::
867
868 real_objects = ModelA.objects.get_real_instances(base_objects_list_or_queryset)
869
870 allows you to turn a queryset or list of base objects into a list of the real instances.
871 This is useful if e.g. you use ``ModelA.base_objects.extra(...)`` and then want to
872 transform the result to its polymorphic equivalent.
873
874 * ``translate_polymorphic_Q_object`` (see DOCS)
875
876 * improved testing
877
878 * Changelog added: CHANGES.rst/html
879
880 Bugfixes
881 ~~~~~~~~
882
883 * Removed requirement for primary key to be an IntegerField.
884 Thanks to Mathieu Steele and Malthe Borch.
885
886 API Changes
887 ~~~~~~~~~~~
888
889 **polymorphic_dumpdata**
890
891 The management command ``polymorphic_dumpdata`` is not needed anymore
892 and has been disabled, as the regular Django dumpdata command now automatically
893 works correctly with polymorphic models (for all supported versions of Django).
894
895 **Output of Queryset or Object Printing**
896
897 In order to improve compatibility with vanilla Django, printing quersets
898 (__repr__ and __unicode__) does not use django_polymorphic's pretty printing
899 by default anymore. To get the old behaviour when printing querysets,
900 you need to replace your model definition:
901
902 >>> class Project(PolymorphicModel):
903
904 by:
905
906 >>> class Project(PolymorphicModel, ShowFieldType):
907
908 The mixin classes for pretty output have been renamed:
909
910 ``ShowFieldTypes, ShowFields, ShowFieldsAndTypes``
911
912 are now:
913
914 ``ShowFieldType, ShowFieldContent and ShowFieldTypeAndContent``
915
916 (the old ones still exist for compatibility)
917
918 **Running the Test suite with Django 1.3**
919
920 Django 1.3 requires ``python manage.py test polymorphic`` instead of
921 just ``python manage.py test``.
922
923
924 Beta Release (2010-2-22)
925 ------------------------
926
927 IMPORTANT: API Changed (import path changed), and Installation Note
928
929 The django_polymorphic source code has been restructured
930 and as a result needs to be installed like a normal Django App
931 - either via copying the "polymorphic" directory into your
932 Django project or by running setup.py. Adding 'polymorphic'
933 to INSTALLED_APPS in settings.py is still optional, however.
934
935 The file `polymorphic.py` cannot be used as a standalone
936 extension module anymore, as is has been split into a number
937 of smaller files.
938
939 Importing works slightly different now: All relevant symbols are
940 imported directly from 'polymorphic' instead from
941 'polymorphic.models'::
942
943 # new way
944 from polymorphic import PolymorphicModel, ...
945
946 # old way, doesn't work anymore
947 from polymorphic.models import PolymorphicModel, ...
948
949 + minor API addition: 'from polymorphic import VERSION, get_version'
950
951 New Features
952 ~~~~~~~~~~~~
953
954 Python 2.4 compatibility, contributed by Charles Leifer. Thanks!
955
956 Bugfixes
957 ~~~~~~~~
958
959 Fix: The exception "...has no attribute 'sub_and_superclass_dict'"
960 could be raised. (This occurred if a subclass defined __init__
961 and accessed class members before calling the superclass __init__).
962 Thanks to Mattias Brändström.
963
964 Fix: There could be name conflicts if
965 field_name == model_name.lower() or similar.
966 Now it is possible to give a field the same name as the class
967 (like with normal Django models).
968 (Found through the example provided by Mattias Brändström)
969
970
971 Beta Release (2010-2-4)
972 -----------------------
973
974 New features (and documentation)
975 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
976
977 queryset order_by method added
978
979 queryset aggregate() and extra() methods implemented
980
981 queryset annotate() method implemented
982
983 queryset values(), values_list(), distinct() documented; defer(),
984 only() allowed (but not yet supported)
985
986 setup.py added. Thanks to Andrew Ingram.
987
988 More about these additions in the docs:
989 ``http://bserve.webhop.org/wiki/django_polymorphic/doc``
990
991 Bugfixes
992 ~~~~~~~~
993
994 * fix remaining potential accessor name clashes (but this only works
995 with Django 1.2+, for 1.1 no changes). Thanks to Andrew Ingram.
996
997 * fix use of 'id' model field, replaced with 'pk'.
998
999 * fix select_related bug for objects from derived classes (till now
1000 sel.-r. was just ignored)
1001
1002 "Restrictions & Caveats" updated
1003 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1004
1005 * Django 1.1 only - the names of polymorphic models must be unique
1006 in the whole project, even if they are in two different apps.
1007 This results from a restriction in the Django 1.1 "related_name"
1008 option (fixed in Django 1.2).
1009
1010 * Django 1.1 only - when ContentType is used in models, Django's
1011 seralisation or fixtures cannot be used. This issue seems to be
1012 resolved for Django 1.2 (changeset 11863: Fixed #7052, Added
1013 support for natural keys in serialization).
1014
1015
1016 Beta Release (2010-1-30)
1017 ------------------------
1018
1019 Fixed ContentType related field accessor clash (an error emitted
1020 by model validation) by adding related_name to the ContentType
1021 ForeignKey. This happened if your polymorphc model used a ContentType
1022 ForeignKey. Thanks to Andrew Ingram.
1023
1024
1025 Beta Release (2010-1-29)
1026 ------------------------
1027
1028 Restructured django_polymorphic into a regular Django add-on
1029 application. This is needed for the management commands, and
1030 also seems to be a generally good idea for future enhancements
1031 as well (and it makes sure the tests are always included).
1032
1033 The ``poly`` app - until now being used for test purposes only
1034 - has been renamed to ``polymorphic``. See DOCS.rst
1035 ("installation/testing") for more info.
1036
1037
1038 Beta Release (2010-1-28)
1039 ------------------------
1040
1041 Added the polymorphic_dumpdata management command (github issue 4),
1042 for creating fixtures, this should be used instead of
1043 the normal Django dumpdata command.
1044 Thanks to Charles Leifer.
1045
1046 Important: Using ContentType together with dumpdata generally
1047 needs Django 1.2 (important as any polymorphic model uses
1048 ContentType).
1049
1050 Beta Release (2010-1-26)
1051 ------------------------
1052
1053 IMPORTANT - database schema change (more info in change log).
1054 I hope I got this change in early enough before anyone started
1055 to use polymorphic.py in earnest. Sorry for any inconvenience.
1056 This should be the final DB schema now.
1057
1058 Django's ContentType is now used instead of app-label and model-name
1059 This is a cleaner and more efficient solution
1060 Thanks to Ilya Semenov for the suggestion.
1061
1062
1063 .. toctree::
1064
1065 drf
1066