From dab3e97c1a83a4c5482f50a671cbf2fc5e16c9ee Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Tue, 3 Nov 2009 15:02:16 +0000 Subject: [PATCH] Fixed #11795 -- Document (and slightly simplify) the use of inlines for m2m relations. This is the first immediate benefit of m2m relations having an autogenerated model. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11712 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/fields/related.py | 3 ++ docs/ref/contrib/admin/index.txt | 66 ++++++++++++++++++++++++++---- 2 files changed, 62 insertions(+), 7 deletions(-) diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index d4e418ea89..2f1193fd60 100644 --- a/django/db/models/fields/related.py +++ b/django/db/models/fields/related.py @@ -586,6 +586,9 @@ class ReverseManyRelatedObjectsDescriptor(object): # ReverseManyRelatedObjectsDescriptor instance. def __init__(self, m2m_field): self.field = m2m_field + # through is provided so that you have easy access to the through + # model (Book.authors.through) for inlines, etc. + self.through = m2m_field.rel.through def __get__(self, instance, instance_type=None): if instance is None: diff --git a/docs/ref/contrib/admin/index.txt b/docs/ref/contrib/admin/index.txt index bd201b2312..0ed3286d48 100644 --- a/docs/ref/contrib/admin/index.txt +++ b/docs/ref/contrib/admin/index.txt @@ -1048,16 +1048,68 @@ automatically:: FriendshipInline, ] +Working with Many-to-Many Models +-------------------------------- + +By default, admin widgets for many-to-many relations will be displayed +on whichever model contains the actual reference to the ``ManyToManyField``. +Depending on your ``ModelAdmin`` definition, each many-to-many field in your +model will be represented by a standard HTML ``