mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #20702 -- Deprecated get_formsets in favor of get_formsets_with_inlines.
Thanks stanislas.guerra at gmail.com for the report.
This commit is contained in:
@@ -453,6 +453,8 @@ these changes.
|
||||
* ``django.db.backends.util``
|
||||
* ``django.forms.util``
|
||||
|
||||
* ``ModelAdmin.get_formsets`` will be removed.
|
||||
|
||||
2.0
|
||||
---
|
||||
|
||||
|
||||
@@ -454,7 +454,7 @@ subclass::
|
||||
.. attribute:: ModelAdmin.inlines
|
||||
|
||||
See :class:`InlineModelAdmin` objects below as well as
|
||||
:meth:`ModelAdmin.get_formsets`.
|
||||
:meth:`ModelAdmin.get_formsets_with_inlines`.
|
||||
|
||||
.. attribute:: ModelAdmin.list_display
|
||||
|
||||
@@ -1365,7 +1365,10 @@ templates used by the :class:`ModelAdmin` views:
|
||||
|
||||
.. method:: ModelAdmin.get_formsets(self, request, obj=None)
|
||||
|
||||
Yields :class:`InlineModelAdmin`\s for use in admin add and change views.
|
||||
.. deprecated:: 1.7
|
||||
Use :meth:`get_formsets_with_inlines()` instead.
|
||||
|
||||
Yields :class:`InlineModelAdmin`\s for use in admin add and change views.
|
||||
|
||||
For example if you wanted to display a particular inline only in the change
|
||||
view, you could override ``get_formsets`` as follows::
|
||||
@@ -1380,6 +1383,24 @@ templates used by the :class:`ModelAdmin` views:
|
||||
continue
|
||||
yield inline.get_formset(request, obj)
|
||||
|
||||
.. method:: ModelAdmin.get_formsets_with_inlines(self, request, obj=None)
|
||||
|
||||
Yields (``FormSet``, :class:`InlineModelAdmin`) pairs for use in admin add
|
||||
and change views.
|
||||
|
||||
For example if you wanted to display a particular inline only in the change
|
||||
view, you could override ``get_formsets_with_inlines`` as follows::
|
||||
|
||||
class MyModelAdmin(admin.ModelAdmin):
|
||||
inlines = [MyInline, SomeOtherInline]
|
||||
|
||||
def get_formsets_with_inlines(self, request, obj=None):
|
||||
for inline in self.get_inline_instances(request, obj):
|
||||
# hide MyInline in the add view
|
||||
if isinstance(inline, MyInline) and obj is None:
|
||||
continue
|
||||
yield inline.get_formset(request, obj), inline
|
||||
|
||||
.. method:: ModelAdmin.formfield_for_foreignkey(self, db_field, request, **kwargs)
|
||||
|
||||
The ``formfield_for_foreignkey`` method on a ``ModelAdmin`` allows you to
|
||||
|
||||
@@ -466,13 +466,13 @@ than simply ``myapp/models.py``, Django would look for :ref:`initial SQL data
|
||||
will search ``myapp/sql/`` as documented. The old location will continue to
|
||||
work until Django 1.9.
|
||||
|
||||
``declared_fieldsets`` attribute on ``ModelAdmin.``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
``declared_fieldsets`` attribute on ``ModelAdmin``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
``ModelAdmin.declared_fieldsets`` was deprecated. Despite being a private API,
|
||||
it will go through a regular deprecation path. This attribute was mostly used
|
||||
by methods that bypassed ``ModelAdmin.get_fieldsets()`` but this was considered
|
||||
a bug and has been addressed.
|
||||
``ModelAdmin.declared_fieldsets`` has been deprecated. Despite being a private
|
||||
API, it will go through a regular deprecation path. This attribute was mostly
|
||||
used by methods that bypassed ``ModelAdmin.get_fieldsets()`` but this was
|
||||
considered a bug and has been addressed.
|
||||
|
||||
``syncdb``
|
||||
~~~~~~~~~~
|
||||
@@ -491,3 +491,10 @@ to ``utils.py`` in an effort to unify all util and utils references:
|
||||
* ``django.contrib.gis.db.backends.util``
|
||||
* ``django.db.backends.util``
|
||||
* ``django.forms.util``
|
||||
|
||||
``get_formsets`` method on ``ModelAdmin``
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
``ModelAdmin.get_formsets`` has been deprecated in favor of the new
|
||||
:meth:`~django.contrib.admin.ModelAdmin.get_formsets_with_inlines`, in order to
|
||||
better handle the case of selecting showing inlines on a ``ModelAdmin``.
|
||||
|
||||
Reference in New Issue
Block a user