mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #17648 -- Add for_concrete_model
to GenericForeignKey
.
Allows a `GenericForeignKey` to reference proxy models. The default for `for_concrete_model` is `True` to keep backwards compatibility. Also added the analog `for_concrete_model` kwarg to `generic_inlineformset_factory` to provide an API at the form level.
This commit is contained in:
parent
8dda8a5ecc
commit
48424adaba
6 changed files with 179 additions and 17 deletions
|
@ -303,6 +303,15 @@ model:
|
|||
:class:`~django.contrib.contenttypes.generic.GenericForeignKey` will
|
||||
look for.
|
||||
|
||||
.. attribute:: GenericForeignKey.for_concrete_model
|
||||
|
||||
.. versionadded:: 1.6
|
||||
|
||||
If ``False``, the field will be able to reference proxy models. Default
|
||||
is ``True``. This mirrors the ``for_concrete_model`` argument to
|
||||
:meth:`~django.contrib.contenttypes.models.ContentTypeManager.get_for_model`.
|
||||
|
||||
|
||||
.. admonition:: Primary key type compatibility
|
||||
|
||||
The "object_id" field doesn't have to be the same type as the
|
||||
|
@ -492,7 +501,7 @@ information.
|
|||
Subclasses of :class:`GenericInlineModelAdmin` with stacked and tabular
|
||||
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, validate_max=False)
|
||||
.. 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, validate_max=False, for_concrete_model=True)
|
||||
|
||||
Returns a ``GenericInlineFormSet`` using
|
||||
:func:`~django.forms.models.modelformset_factory`.
|
||||
|
@ -502,3 +511,9 @@ information.
|
|||
are similar to those documented in
|
||||
:func:`~django.forms.models.modelformset_factory` and
|
||||
:func:`~django.forms.models.inlineformset_factory`.
|
||||
|
||||
.. versionadded:: 1.6
|
||||
|
||||
The ``for_concrete_model`` argument corresponds to the
|
||||
:class:`~django.contrib.contenttypes.generic.GenericForeignKey.for_concrete_model`
|
||||
argument on ``GenericForeignKey``.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue