From ebb3e50243448545c7314a1932a9067ddca5960b Mon Sep 17 00:00:00 2001 From: Loic Bistuer Date: Wed, 31 Jul 2013 12:52:11 +0700 Subject: Introduced ModelAdmin.get_fields() and refactored get_fieldsets() to use it. Refs #18681. This also starts the deprecation of ModelAdmin.declared_fieldsets --- docs/internals/deprecation.txt | 2 ++ docs/ref/contrib/admin/index.txt | 8 ++++++++ docs/releases/1.7.txt | 13 +++++++++++++ 3 files changed, 23 insertions(+) (limited to 'docs') diff --git a/docs/internals/deprecation.txt b/docs/internals/deprecation.txt index 9b0dbf8ffa..fe8b48a5a9 100644 --- a/docs/internals/deprecation.txt +++ b/docs/internals/deprecation.txt @@ -426,6 +426,8 @@ these changes. * ``django.utils.datastructures.SortedDict`` will be removed. Use :class:`collections.OrderedDict` from the Python standard library instead. +* ``ModelAdmin.declared_fieldsets`` will be removed. + 2.0 --- diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt index 40ec514331..04dc52a3a1 100644 --- a/docs/ref/contrib/admin/index.txt +++ b/docs/ref/contrib/admin/index.txt @@ -1218,6 +1218,14 @@ templates used by the :class:`ModelAdmin` views: changelist that will be linked to the change view, as described in the :attr:`ModelAdmin.list_display_links` section. +.. method:: ModelAdmin.get_fields(self, request, obj=None) + + .. versionadded:: 1.7 + + The ``get_fields`` method is given the ``HttpRequest`` and the ``obj`` + being edited (or ``None`` on an add form) and is expected to return a list + of fields, as described above in the :attr:`ModelAdmin.fields` section. + .. method:: ModelAdmin.get_fieldsets(self, request, obj=None) The ``get_fieldsets`` method is given the ``HttpRequest`` and the ``obj`` diff --git a/docs/releases/1.7.txt b/docs/releases/1.7.txt index 91b932aff1..970f362949 100644 --- a/docs/releases/1.7.txt +++ b/docs/releases/1.7.txt @@ -113,6 +113,11 @@ Minor features * The admin's search fields can now be customized per-request thanks to the new :meth:`django.contrib.admin.ModelAdmin.get_search_fields` method. +* The :meth:`ModelAdmin.get_fields() + ` method may be overridden to + customize the value of :attr:`ModelAdmin.fields + `. + Backwards incompatible changes in 1.7 ===================================== @@ -182,3 +187,11 @@ than simply ``myapp/models.py``, Django would look for :ref:`initial SQL data ` in ``myapp/models/sql/``. This bug has been fixed so that Django will search ``myapp/sql/`` as documented. The old location will continue to work until Django 1.9. + +``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. -- cgit v1.3