diff --git a/README.rst b/README.rst index d7c27807..4cbd312e 100644 --- a/README.rst +++ b/README.rst @@ -17,7 +17,7 @@ Microsoft SQL Server and Azure SQL Database. Features -------- -- Supports Django 1.7.4 +- Supports Django 1.7.5 - Supports Microsoft SQL Server 2005, 2008/2008R2, 2012, 2014 and Azure SQL Database - Supports LIMIT+OFFSET and offset w/o LIMIT emulation. @@ -28,7 +28,7 @@ Features Dependencies ------------ -- Django 1.7.4 +- Django 1.7.5 - pyodbc 3.0 or newer Installation diff --git a/setup.py b/setup.py index 0d51e620..c887dc77 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ license='BSD', packages=['sql_server', 'sql_server.pyodbc'], install_requires=[ - 'Django>=1.7.4', + 'Django>=1.7.5,<1.8', 'pyodbc>=3.0', ], classifiers=CLASSIFIERS, diff --git a/sql_server/pyodbc/base.py b/sql_server/pyodbc/base.py index 073850ee..ca06d44f 100644 --- a/sql_server/pyodbc/base.py +++ b/sql_server/pyodbc/base.py @@ -23,7 +23,7 @@ from django.utils.six import binary_type, text_type from django.utils.timezone import utc from django import VERSION as DjangoVersion -if DjangoVersion[:3] >= (1,7,4): +if DjangoVersion[:3] >= (1,7,5): _DJANGO_VERSION = 17 else: raise ImproperlyConfigured("Django %d.%d.%d is not supported." % DjangoVersion[:3]) diff --git a/sql_server/pyodbc/schema.py b/sql_server/pyodbc/schema.py index 2b92a115..376022b4 100644 --- a/sql_server/pyodbc/schema.py +++ b/sql_server/pyodbc/schema.py @@ -4,6 +4,7 @@ from django.db.backends.schema import BaseDatabaseSchemaEditor, logger from django.db.models.fields import AutoField +from django.db.models.fields.related import ManyToManyField from django.utils import six from django.utils.text import force_text @@ -302,7 +303,8 @@ def add_field(self, model, field): table instead (for M2M fields) """ # Special-case implicit M2M tables - if field.get_internal_type() == 'ManyToManyField' and field.rel.through._meta.auto_created: + if ((isinstance(field, ManyToManyField) or field.get_internal_type() == 'ManyToManyField') 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) @@ -470,7 +472,8 @@ def remove_field(self, model, field): but for M2Ms may involve deleting a table. """ # Special-case implicit M2M tables - if field.get_internal_type() == 'ManyToManyField' and field.rel.through._meta.auto_created: + if ((isinstance(field, ManyToManyField) or field.get_internal_type() == 'ManyToManyField') 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: