mirror of
https://github.com/django/django.git
synced 2025-10-28 16:16:12 +00:00
[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
This commit is contained in:
committed by
Tim Graham
parent
0aad1f1ea9
commit
c5c4bfa12a
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user