pythonsql-serverdjangodjango-pyodbcdjango-pyodbc-azure

django-pyodbc-azure 2.1.0.0 not supporting Django 2.1.0


We are trying to connect Django-2.1 with MS SQL Server 2012. We were looking for modules to use for this and stumbled across django-pyodbc-azure. We pip installed it and while restarting the app, we got this following error message:

Unhandled exception in thread started by <function check_errors.<locals>.wrapper
 at 0x0000006140CB2BF8>
Traceback (most recent call last):
  File "C:\Program Files\Python36\lib\site-packages\django\utils\autoreload.py",
 line 225, in wrapper
    fn(*args, **kwargs)
  File "C:\Program Files\Python36\lib\site-packages\django\core\management\comma
nds\runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "C:\Program Files\Python36\lib\site-packages\django\utils\autoreload.py",
 line 248, in raise_last_exception
    raise _exception[1]
  File "C:\Program Files\Python36\lib\site-packages\django\core\management\__ini
t__.py", line 337, in execute
    autoreload.check_errors(django.setup)()
  File "C:\Program Files\Python36\lib\site-packages\django\utils\autoreload.py",
 line 225, in wrapper
    fn(*args, **kwargs)
  File "C:\Program Files\Python36\lib\site-packages\django\__init__.py", line 24
, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Program Files\Python36\lib\site-packages\django\apps\registry.py", li
ne 112, in populate
    app_config.import_models()
  File "C:\Program Files\Python36\lib\site-packages\django\apps\config.py", line
 198, in import_models
    self.models_module = import_module(models_module_name)
  File "C:\Program Files\Python36\lib\importlib\__init__.py", line 126, in impor
t_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Program Files\Python36\lib\site-packages\django\contrib\auth\models.p
y", line 2, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "C:\Program Files\Python36\lib\site-packages\django\contrib\auth\base_use
r.py", line 47, in <module>
    class AbstractBaseUser(models.Model):
  File "C:\Program Files\Python36\lib\site-packages\django\db\models\base.py", l
ine 101, in __new__
    new_class.add_to_class('_meta', Options(meta, app_label))
  File "C:\Program Files\Python36\lib\site-packages\django\db\models\base.py", l
ine 304, in add_to_class
    value.contribute_to_class(cls, name)
  File "C:\Program Files\Python36\lib\site-packages\django\db\models\options.py"
, line 203, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length(
))
  File "C:\Program Files\Python36\lib\site-packages\django\db\__init__.py", line
 33, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "C:\Program Files\Python36\lib\site-packages\django\db\utils.py", line 20
2, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "C:\Program Files\Python36\lib\site-packages\django\db\utils.py", line 11
0, in load_backend
    return import_module('%s.base' % backend_name)
  File "C:\Program Files\Python36\lib\importlib\__init__.py", line 126, in impor
t_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Program Files\Python36\lib\site-packages\sql_server\pyodbc\base.py",
line 11, in <module>
    raise ImproperlyConfigured("Django %d.%d.%d is not supported." % VERSION[:3]
)
django.core.exceptions.ImproperlyConfigured: Django 2.1.0 is not supported.

We have tried many versions of Django such as 2.x, 2.0.4, 2.1 and all version seem to throw the same error which is

Django 2.x.x is not supported.

Database info in settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'sql_server.pyodbc',
        'HOST': 'xxxxxx,1433',
        'USER': 'xxxxxxxx',
        'PASSWORD': 'xxxxxxxx',
        'NAME': 'xxxxxx',
        'OPTIONS': {
            'driver': 'ODBC Driver 17 for SQL Server',
            'host_is_server': True
        },
    }
}

Any leads would be appreciated. Thanks.


Solution

  • This issue resolved by downloading the wheel file of django-pyodbc-azure 2.1.0.0 from https://pypi.org/project/django-pyodbc-azure/#files and installing using the command pip install django_pyodbc_azure-2.1.0.0-py3-none-any.whl.