Skip to content

Commit

Permalink
[1.5.x] Fixed #19477 - Documented generic_inlineformset_factory
Browse files Browse the repository at this point in the history
Thanks epicserve for the suggestion.

Backport of 214fb70 from master
  • Loading branch information
timgraham committed Jan 22, 2013
1 parent 3471839 commit dc0bf53
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion django/contrib/contenttypes/generic.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def generic_inlineformset_factory(model, form=ModelForm,
max_num=None, max_num=None,
formfield_callback=None): formfield_callback=None):
""" """
Returns an ``GenericInlineFormSet`` for the given kwargs. Returns a ``GenericInlineFormSet`` for the given kwargs.
You must provide ``ct_field`` and ``object_id`` if they different from the You must provide ``ct_field`` and ``object_id`` if they different from the
defaults ``content_type`` and ``object_id`` respectively. defaults ``content_type`` and ``object_id`` respectively.
Expand Down
31 changes: 23 additions & 8 deletions docs/ref/contrib/contenttypes.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -452,14 +452,18 @@ need to calculate them without using the aggregation API.
Generic relations in forms and admin Generic relations in forms and admin
------------------------------------ ------------------------------------


The :mod:`django.contrib.contenttypes.generic` module provides The :mod:`django.contrib.contenttypes.generic` module provides:
``BaseGenericInlineFormSet``,
:class:`~django.contrib.contenttypes.generic.GenericTabularInline` * ``BaseGenericInlineFormSet``
and :class:`~django.contrib.contenttypes.generic.GenericStackedInline` * :class:`~django.contrib.contenttypes.generic.GenericTabularInline`
(the last two are subclasses of and :class:`~django.contrib.contenttypes.generic.GenericStackedInline`
:class:`~django.contrib.contenttypes.generic.GenericInlineModelAdmin`). (subclasses of
This enables the use of generic relations in forms and the admin. See the :class:`~django.contrib.contenttypes.generic.GenericInlineModelAdmin`)
:doc:`model formset </topics/forms/modelforms>` and * A formset factory, :func:`generic_inlineformset_factory`, for use with
:class:`GenericForeignKey`

These classes and functions enable the use of generic relations in forms
and the admin. See the :doc:`model formset </topics/forms/modelforms>` and
:ref:`admin <using-generic-relations-as-an-inline>` documentation for more :ref:`admin <using-generic-relations-as-an-inline>` documentation for more
information. information.


Expand All @@ -486,3 +490,14 @@ information.


Subclasses of :class:`GenericInlineModelAdmin` with stacked and tabular Subclasses of :class:`GenericInlineModelAdmin` with stacked and tabular
layouts, respectively. layouts, respectively.

.. function:: generic_inlineformset_factory(model, form=ModelForm, formset=BaseGenericInlineFormSet, ct_field="content_type", fk_field="object_id", fields=None, exclude=None, extra=3, can_order=False, can_delete=True, max_num=None, formfield_callback=None)

Returns a ``GenericInlineFormSet`` using
:func:`~django.forms.models.modelformset_factory`.

You must provide ``ct_field`` and ``object_id`` if they different from the
defaults, ``content_type`` and ``object_id`` respectively. Other parameters
are similar to those documented in
:func:`~django.forms.models.modelformset_factory` and
:func:`~django.forms.models.inlineformset_factory`.

0 comments on commit dc0bf53

Please sign in to comment.