summaryrefslogtreecommitdiff
path: root/django
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 09:08:45 -0400
commitf58392d8d8b68e2e7777768f39941cd995ce16e4 (patch)
tree5ffe8def9205e5a594fcfa4fe95714b1e25c74a7 /django
parentdf657a768248c07fdbdc950b08366f655d0f2f5d (diff)
[1.4.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')
-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 0bf9ede6cb..12291605ee 100644
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -281,6 +281,11 @@ class BaseModelAdmin(object):
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()