diff options
| author | tschilling <schillingt@better-simple.com> | 2013-09-03 21:01:45 -0400 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2013-09-20 07:47:24 -0400 |
| commit | 0d1ba84d13eb6000c9f6e54b03d52863fcd31f27 (patch) | |
| tree | 02f448190c944e7c7fcdf45e41adad71db1b4da3 /docs/ref | |
| parent | f8f47718abb4c93ef00f93dde42101a8dd17a700 (diff) | |
Fixed #20702 -- Deprecated get_formsets in favor of get_formsets_with_inlines.
Thanks stanislas.guerra at gmail.com for the report.
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/contrib/admin/index.txt | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt index dd31d11dee..2e02785e81 100644 --- a/docs/ref/contrib/admin/index.txt +++ b/docs/ref/contrib/admin/index.txt @@ -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 |
