summaryrefslogtreecommitdiff
path: root/django/contrib
diff options
context:
space:
mode:
authorEmmanuelle Delescolle <emma@lasolution.be>2014-10-05 20:06:51 +0200
committerTim Graham <timograham@gmail.com>2014-10-06 08:50:48 -0400
commitc5c4bfa12aa0e8d4e8b46d77b6159f59330c3313 (patch)
tree03088f50319043be629a48010e5642fa212456ad /django/contrib
parent0aad1f1ea912e1c855c1ff9c0b89fa28d2035ca3 (diff)
[1.6.x] Fixed #23604 -- Allowed related m2m fields to be references in the admin.
Thanks Simon Charette for review. Backport of a24cf21722 from master
Diffstat (limited to 'django/contrib')
-rw-r--r--django/contrib/admin/options.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index 0b7a6ae7d9..a0b816ccf0 100644
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -339,6 +339,11 @@ class BaseModelAdmin(six.with_metaclass(RenameBaseModelAdminMethods)):
except FieldDoesNotExist:
return False
+ # Check whether this model is the origin of a M2M relationship
+ # in which case to_field has to be the pk on this model.
+ if opts.many_to_many and field.primary_key:
+ return True
+
# Make sure at least one of the models registered for this site
# references this field through a FK or a M2M relationship.
registered_models = set()