summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2016-03-10 18:21:25 +0100
committerClaude Paroz <claude@2xlibre.net>2016-03-19 09:24:27 +0100
commit983c158da7723eb00a376bd31db76709da4d0260 (patch)
treed5784910f91a4e8a5ee31bd376796c70b6463e37 /django/forms
parent2b3a9414570af623853ca0f819c7d77d0511f22c (diff)
Refs #24227 -- Replaced M2M isinstance checks by field.many_to_many
Thanks Markus Holtermann, Collin Anderson and Tim Graham for the reviews.
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/models.py4
1 files changed, 1 insertions, 3 deletions
diff --git a/django/forms/models.py b/django/forms/models.py
index 4422882315..067f601493 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -79,8 +79,6 @@ def model_to_dict(instance, fields=None, exclude=None):
fields will be excluded from the returned dict, even if they are listed in
the ``fields`` argument.
"""
- # avoid a circular import
- from django.db.models.fields.related import ManyToManyField
opts = instance._meta
data = {}
for f in chain(opts.concrete_fields, opts.virtual_fields, opts.many_to_many):
@@ -90,7 +88,7 @@ def model_to_dict(instance, fields=None, exclude=None):
continue
if exclude and f.name in exclude:
continue
- if isinstance(f, ManyToManyField):
+ if f.many_to_many:
# If the object doesn't have a primary key yet, just use an empty
# list for its m2m fields. Calling f.value_from_object will raise
# an exception.