Fixed #13307 -- Enhanced the generic inlines documentation by mentioning the concrete Generic{Tabular,Stacked}Inline classes that should be used. Thanks loki77 for the report.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15124 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Ramiro Morales 2010-12-31 23:02:07 +00:00
parent 5a36b43c27
commit 70c8cd4100
2 changed files with 17 additions and 11 deletions

View File

@ -1364,6 +1364,8 @@ Finally, register your ``Person`` and ``Group`` models with the admin site::
Now your admin site is set up to edit ``Membership`` objects inline from Now your admin site is set up to edit ``Membership`` objects inline from
either the ``Person`` or the ``Group`` detail pages. either the ``Person`` or the ``Group`` detail pages.
.. _using-generic-relations-as-an-inline:
Using generic relations as an inline Using generic relations as an inline
------------------------------------ ------------------------------------
@ -1380,9 +1382,12 @@ you have the following models::
name = models.CharField(max_length=100) name = models.CharField(max_length=100)
If you want to allow editing and creating ``Image`` instance on the ``Product`` If you want to allow editing and creating ``Image`` instance on the ``Product``
add/change views you can simply use ``GenericInlineModelAdmin`` provided by add/change views you can use ``GenericTabularInline`` or
``django.contrib.contenttypes.generic``. In your ``admin.py`` for this ``GenericStackedInline`` (both subclasses of ``GenericInlineModelAdmin``)
example app:: provided by ``django.contrib.contenttypes.generic``, they implement tabular and
stacked visual layouts for the forms representing the inline objects
respectively just like their non-generic counterparts and behave just like any
other inline. In your ``admin.py`` for this example app::
from django.contrib import admin from django.contrib import admin
from django.contrib.contenttypes import generic from django.contrib.contenttypes import generic
@ -1399,10 +1404,8 @@ example app::
admin.site.register(Product, ProductAdmin) admin.site.register(Product, ProductAdmin)
``django.contrib.contenttypes.generic`` provides both a ``GenericTabularInline`` See the :doc:`contenttypes documentation </ref/contrib/contenttypes>` for more
and ``GenericStackedInline`` and behave just like any other inline. See the specific information.
:doc:`contenttypes documentation </ref/contrib/contenttypes>` for more specific
information.
Overriding Admin Templates Overriding Admin Templates
========================== ==========================

View File

@ -369,12 +369,15 @@ relations, you'll need to calculate them without using the aggregation API.
Generic relations in forms and admin Generic relations in forms and admin
------------------------------------ ------------------------------------
:mod:`django.contrib.contenttypes.generic` provides both a :mod:`django.contrib.contenttypes.generic` provides
:class:`~django.contrib.contenttypes.generic.GenericInlineFormSet` :class:`~django.contrib.contenttypes.generic.GenericInlineFormSet`,
and :class:`~django.contrib.contenttypes.generic.GenericInlineModelAdmin`. :class:`~django.contrib.contenttypes.generic.GenericTabularInline`
and :class:`~django.contrib.contenttypes.generic.GenericStackedInline`
(the last two subclasses of :class:`~django.contrib.contenttypes.generic.GenericInlineModelAdmin`).
This enables the use of generic relations in forms and the admin. See the This enables the use of generic relations in forms and the admin. See the
:doc:`model formset </topics/forms/modelforms>` and :doc:`model formset </topics/forms/modelforms>` and
:doc:`admin </ref/contrib/admin/index>` documentation for more information. :ref:`admin <using-generic-relations-as-an-inline>` documentation for more
information.
.. class:: generic.GenericInlineModelAdmin .. class:: generic.GenericInlineModelAdmin