summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorAndriy Sokolovskiy <sokandpal@yandex.ru>2015-01-09 00:51:00 +0200
committerMarkus Holtermann <info@markusholtermann.eu>2015-01-22 18:41:19 +0100
commit38c17871bb6dafd489367f6fe8bc56199223adb8 (patch)
treefbd65ffaa46f30d49b3e29ea0999090647ef6921 /django
parentd450af8a2687ca2e90a8790eb567f9a25ebce85b (diff)
Fixed #24104 -- Fixed check to look on field.many_to_many instead of class instance
Diffstat (limited to 'django')
-rw-r--r--django/db/backends/base/schema.py5
-rw-r--r--django/db/backends/sqlite3/schema.py9
2 files changed, 6 insertions, 8 deletions
diff --git a/django/db/backends/base/schema.py b/django/db/backends/base/schema.py
index 09db3f1096..8ec92ebf6a 100644
--- a/django/db/backends/base/schema.py
+++ b/django/db/backends/base/schema.py
@@ -1,7 +1,6 @@
import hashlib
from django.db.backends.utils import truncate_name
-from django.db.models.fields.related import ManyToManyField
from django.db.transaction import atomic
from django.utils import six
from django.utils.encoding import force_bytes
@@ -380,7 +379,7 @@ class BaseDatabaseSchemaEditor(object):
table instead (for M2M fields)
"""
# Special-case implicit M2M tables
- if isinstance(field, ManyToManyField) and field.rel.through._meta.auto_created:
+ if field.many_to_many and field.rel.through._meta.auto_created:
return self.create_model(field.rel.through)
# Get the column's definition
definition, params = self.column_sql(model, field, include_default=True)
@@ -424,7 +423,7 @@ class BaseDatabaseSchemaEditor(object):
but for M2Ms may involve deleting a table.
"""
# Special-case implicit M2M tables
- if isinstance(field, ManyToManyField) and field.rel.through._meta.auto_created:
+ if field.many_to_many and field.rel.through._meta.auto_created:
return self.delete_model(field.rel.through)
# It might not actually have a column behind it
if field.db_parameters(connection=self.connection)['type'] is None:
diff --git a/django/db/backends/sqlite3/schema.py b/django/db/backends/sqlite3/schema.py
index 814b94ffee..031bf77840 100644
--- a/django/db/backends/sqlite3/schema.py
+++ b/django/db/backends/sqlite3/schema.py
@@ -4,7 +4,6 @@ from decimal import Decimal
from django.apps.registry import Apps
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
-from django.db.models.fields.related import ManyToManyField
from django.utils import six
import _sqlite3
@@ -71,7 +70,7 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
for field in create_fields:
body[field.name] = field
# Choose a default and insert it into the copy map
- if not isinstance(field, ManyToManyField):
+ if not field.many_to_many:
mapping[field.column] = self.quote_value(
self.effective_default(field)
)
@@ -94,7 +93,7 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
del body[field.name]
del mapping[field.column]
# Remove any implicit M2M tables
- if isinstance(field, ManyToManyField) and field.rel.through._meta.auto_created:
+ if field.many_to_many and field.rel.through._meta.auto_created:
return self.delete_model(field.rel.through)
# Work inside a new app registry
apps = Apps()
@@ -173,7 +172,7 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
table instead (for M2M fields)
"""
# Special-case implicit M2M tables
- if isinstance(field, ManyToManyField) and field.rel.through._meta.auto_created:
+ if field.many_to_many and field.rel.through._meta.auto_created:
return self.create_model(field.rel.through)
self._remake_table(model, create_fields=[field])
@@ -183,7 +182,7 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
but for M2Ms may involve deleting a table.
"""
# M2M fields are a special case
- if isinstance(field, ManyToManyField):
+ if field.many_to_many:
# For implicit M2M tables, delete the auto-created table
if field.rel.through._meta.auto_created:
self.delete_model(field.rel.through)