peering-manager / docker

🐳 Docker Image of Peering Manager
Apache License 2.0
9 stars 13 forks source link

Cannot import url from django.conf.urls #19

Closed rfdrake closed 2 years ago

rfdrake commented 2 years ago

For some reason the docker images are being built with Django 4.0 instead of 3.x. I tried both the "latest" image and the "snapshot" image and got the same problem:

peering-manager_1         | /opt/peering-manager/peering_manager/settings.py:51: UserWarning: MY_ASN is no longer supported and will be removed in 2.0.
peering-manager_1         |   warnings.warn("MY_ASN is no longer supported and will be removed in 2.0.")
peering-manager_1         | /opt/peering-manager/peering_manager/settings.py:265: UserWarning: DEFAULT_TIMEOUT is no longer supported under REDIS configuration. Set RQ_DEFAULT_TIMEOUT instead.
peering-manager_1         |   warnings.warn(
 peering-manager_1         | Traceback (most recent call last):
peering-manager_1         |   File "/opt/peering-manager/./manage.py", line 11, in <module>
peering-manager_1         |     execute_from_command_line(sys.argv)
peering-manager_1         |   File "/usr/local/lib/python3.10/site-packages/django/core/management/__init__.py", line 425, in execute_from_command_line
peering-manager_1         |     utility.execute()
peering-manager_1         |   File "/usr/local/lib/python3.10/site-packages/django/core/management/__init__.py", line 419, in execute
peering-manager_1         |     self.fetch_command(subcommand).run_from_argv(self.argv)
peering-manager_1         |   File "/usr/local/lib/python3.10/site-packages/django/core/management/base.py", line 373, in run_from_argv
peering-manager_1         |     self.execute(*args, **cmd_options)
peering-manager_1         |   File "/usr/local/lib/python3.10/site-packages/django/core/management/base.py", line 417, in execute
peering-manager_1         |     output = self.handle(*args, **options)
peering-manager_1         |   File "/usr/local/lib/python3.10/site-packages/django/core/management/base.py", line 90, in wrapped
peering-manager_1         |     res = handle_func(*args, **kwargs)
peering-manager_1         |   File "/usr/local/lib/python3.10/site-packages/django/core/management/commands/migrate.py", line 75, in handle
peering-manager_1         |     self.check(databases=[database])
peering-manager_1         |   File "/usr/local/lib/python3.10/site-packages/django/core/management/base.py", line 438, in check
peering-manager_1         |     all_issues = checks.run_checks(
peering-manager_1         |   File "/usr/local/lib/python3.10/site-packages/django/core/checks/registry.py", line 77, in run_checks
peering-manager_1         |     new_errors = check(app_configs=app_configs, databases=databases)
peering-manager_1         |   File "/usr/local/lib/python3.10/site-packages/django/core/checks/urls.py", line 13, in check_url_config
peering-manager_1         |     return check_resolver(resolver)
peering-manager_1         |   File "/usr/local/lib/python3.10/site-packages/django/core/checks/urls.py", line 23, in check_resolver
peering-manager_1         |     return check_method()
peering-manager_1         |   File "/usr/local/lib/python3.10/site-packages/django/urls/resolvers.py", line 446, in check
peering-manager_1         |     for pattern in self.url_patterns:
peering-manager_1         |   File "/usr/local/lib/python3.10/site-packages/django/utils/functional.py", line 48, in __get__
peering-manager_1         |     res = instance.__dict__[self.name] = self.func(instance)
peering-manager_1         |   File "/usr/local/lib/python3.10/site-packages/django/urls/resolvers.py", line 632, in url_patterns
peering-manager_1         |     patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
peering-manager_1         |   File "/usr/local/lib/python3.10/site-packages/django/utils/functional.py", line 48, in __get__
peering-manager_1         |     res = instance.__dict__[self.name] = self.func(instance)
peering-manager_1         |   File "/usr/local/lib/python3.10/site-packages/django/urls/resolvers.py", line 625, in urlconf_module
peering-manager_1         |     return import_module(self.urlconf_name)
peering-manager_1         |   File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
peering-manager_1         |     return _bootstrap._gcd_import(name[level:], package, level)
peering-manager_1         |   File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
peering-manager_1         |   File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
peering-manager_1         |   File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
peering-manager_1         |   File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
peering-manager_1         |   File "<frozen importlib._bootstrap_external>", line 883, in exec_module
peering-manager_1         |   File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
peering-manager_1         |   File "/opt/peering-manager/peering_manager/urls.py", line 2, in <module>
peering-manager_1         |     from django.conf.urls import include, url
peering-manager_1         | ImportError: cannot import name 'url' from 'django.conf.urls' (/usr/local/lib/python3.10/site-packages/django/conf/urls/__init__.py)
peering-manager_1         | ⏳ Waiting on DB... (24s / 30s)

Running "pip list" inside the container shows it's using Django 4.0 despite the requirements file saying >=3.2,<3.3.

gmazoyer commented 2 years ago

It looks like a package installed by https://github.com/peering-manager/docker/blob/9ae083caed413607164529ceb3d6df845bd70299/Dockerfile#L25 is causing the issue and overrides the pinned Django version found in requirements.txt.

gmazoyer commented 2 years ago

Can you test the latest image (pushed a few seconds ago) to see if it fixes this issue?

rfdrake commented 2 years ago

That fixed it. Thanks very much!