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 ``