Django Navigation

Hello,

Would anyone be able to help me resolve errors in relation to installing Django Navigation?

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Users\Administrator.WIN-GFIFKQL9F4R.000>cd C:\inetpub\FaulknerandSonsLTD2\Pyt
hon\Scripts

C:\inetpub\FaulknerandSonsLTD2\Python\Scripts>manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Users\Administrator.WIN-GFIFKQL9F4R.000\AppData\Local\Programs\Python
\Python38\lib\threading.py", line 932, in _bootstrap_inner
self.run()
  File "C:\Users\Administrator.WIN-GFIFKQL9F4R.000\AppData\Local\Programs\Python
\Python38\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
  File "C:\Users\Administrator.WIN-GFIFKQL9F4R.000\AppData\Local\Programs\Python
\Python38\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
  File "C:\Users\Administrator.WIN-GFIFKQL9F4R.000\AppData\Local\Programs\Python
\Python38\lib\site-packages\django\core\management\commands\runserver.py", line
109, in inner_run
autoreload.raise_last_exception()
  File "C:\Users\Administrator.WIN-GFIFKQL9F4R.000\AppData\Local\Programs\Python
\Python38\lib\site-packages\django\utils\autoreload.py", line 76, in raise_last_
exception
raise _exception[1]
  File "C:\Users\Administrator.WIN-GFIFKQL9F4R.000\AppData\Local\Programs\Python
\Python38\lib\site-packages\django\core\management\__init__.py", line 357, in ex
ecute
autoreload.check_errors(django.setup)()
  File "C:\Users\Administrator.WIN-GFIFKQL9F4R.000\AppData\Local\Programs\Python
\Python38\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
  File "C:\Users\Administrator.WIN-GFIFKQL9F4R.000\AppData\Local\Programs\Python
\Python38\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\Administrator.WIN-GFIFKQL9F4R.000\AppData\Local\Programs\Python
\Python38\lib\site-packages\django\apps\registry.py", line 114, in populate
app_config.import_models()
  File "C:\Users\Administrator.WIN-GFIFKQL9F4R.000\AppData\Local\Programs\Python
\Python38\lib\site-packages\django\apps\config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
  File "C:\Users\Administrator.WIN-GFIFKQL9F4R.000\AppData\Local\Programs\Python
\Python38\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\inetpub\FaulknerandSonsLTD2\Python\Scripts\Accounts\models.py", line
5, in <module>
class Member(models.Model):
  File "C:\Users\Administrator.WIN-GFIFKQL9F4R.000\AppData\Local\Programs\Python
\Python38\lib\site-packages\django\db\models\base.py", line 160, in __new__
new_class.add_to_class(obj_name, obj)
  File "C:\Users\Administrator.WIN-GFIFKQL9F4R.000\AppData\Local\Programs\Python
\Python38\lib\site-packages\django\db\models\base.py", line 325, in add_to_class

value.contribute_to_class(cls, name)
  File "C:\Users\Administrator.WIN-GFIFKQL9F4R.000\AppData\Local\Programs\Python
\Python38\lib\site-packages\django\db\models\fields\related.py", line 1585, in c
ontribute_to_class
self.remote_field.through = create_many_to_many_intermediary_model(self, cls
)
  File "C:\Users\Administrator.WIN-GFIFKQL9F4R.000\AppData\Local\Programs\Python
\Python38\lib\site-packages\django\db\models\fields\related.py", line 1061, in c
reate_many_to_many_intermediary_model
'db_table': field._get_m2m_db_table(klass._meta),
  File "C:\Users\Administrator.WIN-GFIFKQL9F4R.000\AppData\Local\Programs\Python
\Python38\lib\site-packages\django\db\models\fields\related.py", line 1506, in _
get_m2m_db_table
return utils.truncate_name(m2m_table_name, connection.ops.max_name_length())

  File "C:\Users\Administrator.WIN-GFIFKQL9F4R.000\AppData\Local\Programs\Python
\Python38\lib\site-packages\django\db\__init__.py", line 28, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "C:\Users\Administrator.WIN-GFIFKQL9F4R.000\AppData\Local\Programs\Python
\Python38\lib\site-packages\django\db\utils.py", line 207, in __getitem__
backend = load_backend(db['ENGINE'])
  File "C:\Users\Administrator.WIN-GFIFKQL9F4R.000\AppData\Local\Programs\Python
\Python38\lib\site-packages\django\db\utils.py", line 111, in load_backend
return import_module('%s.base' % backend_name)
  File "C:\Users\Administrator.WIN-GFIFKQL9F4R.000\AppData\Local\Programs\Python
\Python38\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\Administrator.WIN-GFIFKQL9F4R.000\AppData\Local\Programs\Python
\Python38\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 3.0.3 is not supported.

My first guess would be that django-navigation or some of it’s dependencies doesn’t support Django 3.x. Which would make sense since it’s last commit has been done 4 years ago: https://github.com/rrafal/django-navigation

But looking more carefully, it looks like something with your database engine. Are you using SQL Server? Which backend are you using?

Yes, I installed various different django navigation related pip packages recently and I think it is this that has caused the issue. I’ve since uninstalled them all but the problem hasn’t gone away.

SQL Server engine should be fine since I have been using this without error for some time.

Would we be able to connect to resolve?

I might be getting the wrong impression, but the tail of the log you’ve pasted is raising an issue with the sql_server/pyodbc package:

File "C:\Users\Administrator.WIN-GFIFKQL9F4R.000\AppData\Local\Programs\Python
\Python38\lib\site-packages\sql_server\pyodbc\base.py", line 11, in <module>
raise ImproperlyConfigured("Django %d.%d.%d is not supported." % VERSION[:3]
)

I’ve never used SQL Server before, so I’m not sure about how to configure it with Django. After googling it a little bit, my guess would be that you are using the django_pyodbc backend, and it doesn’t support Django 3.0:

Can you confirm which database engine you are using?

I am using pyodbc to connect to SQL server although I have noted that the pyodbc package doesn’t seem to be kept as up to date as Django. The version of pyodbc that I am using is 1.1.3.

All databases that the application uses are stored in Microsoft SQL Server - so I am using the SQL Server Engine per se, which links to Django using Pyodbc. Hope this makes sense.

@nfaulkner90, it does make sense.

Reading the oficial Django 3 Documentation (https://docs.djangoproject.com/en/3.0/ref/databases/#using-a-3rd-party-database-backend), SQL Server is not part of the officially supported databases. But they seem to recommend the use of django-pyodbc-azure (https://pypi.org/project/django-pyodbc-azure/) and django-pyodbc (already mentioned here before).

But still, none of them seem to work with Django 3: https://github.com/michiya/django-pyodbc-azure/blob/azure-2.1/sql_server/pyodbc/base.py#L12 and https://github.com/lionheart/django-pyodbc/blob/master/django_pyodbc/base.py#L85.

The only suggestion that I can make right now would be downgrading your Django version to 2.1, which is the version supported by https://pypi.org/project/django-pyodbc-azure/. And looking to the Django Navigation commit history, I think it would be a good fit also (it doesn’t seem to be Django 3 compliant as well):

Reference:

1 Like

Actually, you can try https://github.com/ESSolutions/django-mssql-backend, which seems to support Django 2.2 (LTS) and Django 3.

You are a star! Thank you.

Next error which I’m sure has an easy answer is:

(staticfiles.E001) The STATICFILES_DIRS setting is not a tuple or a list. Hint: 
Perhaps you forgot a trailing comma? 

ROOT_PATH = os.path.dirname(file)

STATIC_PATH = os.path.join(ROOT_PATH, ‘static’)

STATIC_URL = ‘https://%s/%s/’ % (AWS_S3_CUSTOM_DOMAIN, AWS_LOCATION)

STATICFILES_DIRS=(
STATIC_PATH
)

DEFAULT_FILES_STORAGE = ‘DjangoWebProject1.custom_storage.MediaStorage’

A warning pops up as follows:

URL namespace 'PurchaseOrders' isn't unique. You may not be able to reverse all URLs in this namespace.

Any guidance, much appreciated.

As the error message is stating, your configuration is missing a trailing comma.

STATICFILES_DIRS = (STATIC_PATH)

The above is what your settings have currently. This is not a tuple. Python will interpret that as parentheses only so the setting is equivalent to STATICFILES_DIRS = STATIC_PATH. You must add a trailing comma to a single element tuple in order for Python to recognize it as a tuple.

# Note the trailing comma after STATIC_PATH!
STATICFILES_DIRS = (STATIC_PATH,)

Thank you for your help, very greatful. I have one last query regarding the warning quoted above.

Have you tried that Django3.0+ connects to SQL Server and did it work? I happen to have the same problem,Django3.0+ connects to SQL Server Can you help me?