Clarified the intermediary models admin documentation and a minor clean-up.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@8209 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
ac69520890
commit
40cd410955
|
@ -691,7 +691,7 @@ Working with Many-to-Many Intermediary Models
|
||||||
----------------------------------------------
|
----------------------------------------------
|
||||||
|
|
||||||
By default, admin widgets for many-to-many relations will be displayed inline
|
By default, admin widgets for many-to-many relations will be displayed inline
|
||||||
on whichever model contains the actual reference to the `ManyToManyField`.
|
on whichever model contains the actual reference to the ``ManyToManyField``.
|
||||||
However, when you specify an intermediary model using the ``through``
|
However, when you specify an intermediary model using the ``through``
|
||||||
argument to a ``ManyToManyField``, the admin will not display a widget by
|
argument to a ``ManyToManyField``, the admin will not display a widget by
|
||||||
default. This is because each instance of that intermediary model requires
|
default. This is because each instance of that intermediary model requires
|
||||||
|
@ -716,15 +716,15 @@ models::
|
||||||
invite_reason = models.CharField(max_length=64)
|
invite_reason = models.CharField(max_length=64)
|
||||||
|
|
||||||
The first step in displaying this intermediate model in the admin is to
|
The first step in displaying this intermediate model in the admin is to
|
||||||
define an inline model for the Membership table::
|
define an inline class for the ``Membership`` model::
|
||||||
|
|
||||||
class MembershipInline(admin.TabularInline):
|
class MembershipInline(admin.TabularInline):
|
||||||
model = Membership
|
model = Membership
|
||||||
extra = 1
|
extra = 1
|
||||||
|
|
||||||
This simple example uses the defaults inline form for the Membership model,
|
This simple example uses the default ``InlineModelAdmin`` values for the
|
||||||
and shows 1 extra line. This could be customized using any of the options
|
``Membership`` model, and limits the extra add forms to one. This could be
|
||||||
available to inline models.
|
customized using any of the options available to ``InlineModelAdmin`` classes.
|
||||||
|
|
||||||
Now create admin views for the ``Person`` and ``Group`` models::
|
Now create admin views for the ``Person`` and ``Group`` models::
|
||||||
|
|
||||||
|
@ -739,8 +739,8 @@ Finally, register your ``Person`` and ``Group`` models with the admin site::
|
||||||
admin.site.register(Person, PersonAdmin)
|
admin.site.register(Person, PersonAdmin)
|
||||||
admin.site.register(Group, GroupAdmin)
|
admin.site.register(Group, GroupAdmin)
|
||||||
|
|
||||||
Now your admin site is set up to edit ``Membership`` objects inline from either
|
Now your admin site is set up to edit ``Membership`` objects inline from
|
||||||
the ``Person`` or the ``Group`` detail pages.
|
either the ``Person`` or the ``Group`` detail pages.
|
||||||
|
|
||||||
``AdminSite`` objects
|
``AdminSite`` objects
|
||||||
=====================
|
=====================
|
||||||
|
|
Loading…
Reference in New Issue