Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] cannot import name 'url' from 'django.conf.urls' #2008

Closed
1 task done
tswfi opened this issue Dec 18, 2021 · 6 comments · Fixed by #2009
Closed
1 task done

[BUG] cannot import name 'url' from 'django.conf.urls' #2008

tswfi opened this issue Dec 18, 2021 · 6 comments · Fixed by #2009

Comments

@tswfi
Copy link
Contributor

tswfi commented Dec 18, 2021

Is there an existing issue for this?

  • I have searched the existing Issues

Current Behavior

following the "quick start" info from the homepage and going around bug #2007 by manually installing pytz with

pipenv install pytz

Comes the next problem:

demo> ./manage.py createdb
Traceback (most recent call last):
  File "/home/tsw/git/mezzazine_vanilla/myproject/./manage.py", line 14, in <module>
    execute_from_command_line(sys.argv)
  File "/home/tsw/.local/share/virtualenvs/mezzazine_vanilla-ZPLJQPDu/lib/python3.9/site-packages/django/core/management/__init__.py", line 425, in execute_from_command_line
    utility.execute()
  File "/home/tsw/.local/share/virtualenvs/mezzazine_vanilla-ZPLJQPDu/lib/python3.9/site-packages/django/core/management/__init__.py", line 401, in execute
    django.setup()
  File "/home/tsw/.local/share/virtualenvs/mezzazine_vanilla-ZPLJQPDu/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/tsw/.local/share/virtualenvs/mezzazine_vanilla-ZPLJQPDu/lib/python3.9/site-packages/django/apps/registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
  File "/home/tsw/.local/share/virtualenvs/mezzazine_vanilla-ZPLJQPDu/lib/python3.9/site-packages/django/apps/config.py", line 223, in create
    import_module(entry)
  File "/usr/lib64/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/tsw/.local/share/virtualenvs/mezzazine_vanilla-ZPLJQPDu/lib/python3.9/site-packages/mezzanine/boot/__init__.py", line 18, in <module>
    from mezzanine.boot.lazy_admin import LazyAdminSite
  File "/home/tsw/.local/share/virtualenvs/mezzazine_vanilla-ZPLJQPDu/lib/python3.9/site-packages/mezzanine/boot/lazy_admin.py", line 2, in <module>
    from django.conf.urls import include, url
ImportError: cannot import name 'url' from 'django.conf.urls' (/home/tsw/.local/share/virtualenvs/mezzazine_vanilla-ZPLJQPDu/lib/python3.9/site-packages/django/conf/urls/__init__.py)
demo> 

Expected Behavior

The database is created with the command manage.py createdb

Steps To Reproduce

follow the quick start from homepage. Work around #2007 by also installing pytz

Environment

- Operating System: linux
- Python version: 3.9.9
- Django version: 4.0.0
- Database engine and version: I'm guessing the "quick start" from homepage defaults to sqlite? didn't get that far.
- Mezzanine version: 5.0.0

Anything else?

I'm guessing this comes from the fact that django has deprecated django.conf.urls.url in version 3.1 (https://docs.djangoproject.com/en/3.2/ref/urls/#url) and django.urls.re_path() should be used instead. Of course migrating to the new path format might be even better as it is much nicer to read (https://docs.djangoproject.com/en/4.0/ref/urls/)

@skru
Copy link

skru commented Dec 19, 2021

Please trying installing with mezzanine with:

pip install mezzanine==5.0.0

That'll install Django==3.2.10 which still uses django.conf.urls

@tswfi
Copy link
Contributor Author

tswfi commented Dec 19, 2021

Please trying installing with mezzanine with:

pip install mezzanine==5.0.0

That'll install Django==3.2.10 which still uses django.conf.urls

Nope, didn't help. On ubuntu:latest with just pip installed from apt:

root@fa8f13968417:/tmp/mezzanine# pip install mezzanine==5.0.0
Collecting mezzanine==5.0.0
  Downloading Mezzanine-5.0.0-py2.py3-none-any.whl (6.0 MB)
     |████████████████████████████████| 6.0 MB 3.3 MB/s 
Collecting pillow>=7
  Downloading Pillow-8.4.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.1 MB)
     |████████████████████████████████| 3.1 MB 538 kB/s 
Collecting chardet>=4
  Downloading chardet-4.0.0-py2.py3-none-any.whl (178 kB)
     |████████████████████████████████| 178 kB 546 kB/s 
Collecting requests-oauthlib>=1.3
  Downloading requests_oauthlib-1.3.0-py2.py3-none-any.whl (23 kB)
Collecting requests>=2.1.0
  Downloading requests-2.26.0-py2.py3-none-any.whl (62 kB)
     |████████████████████████████████| 62 kB 281 kB/s 
Collecting beautifulsoup4>=4.5.3
  Downloading beautifulsoup4-4.10.0-py3-none-any.whl (97 kB)
     |████████████████████████████████| 97 kB 1.1 MB/s 
Collecting bleach>=2
  Downloading bleach-4.1.0-py2.py3-none-any.whl (157 kB)
     |████████████████████████████████| 157 kB 1.6 MB/s 
Collecting tzlocal>=2
  Downloading tzlocal-4.1-py3-none-any.whl (19 kB)
Collecting filebrowser-safe>=1.0.0
  Downloading filebrowser_safe-1.0.0-py2.py3-none-any.whl (133 kB)
     |████████████████████████████████| 133 kB 1.6 MB/s 
Collecting grappelli-safe>=1.0.0
  Downloading grappelli_safe-1.0.0-py2.py3-none-any.whl (163 kB)
     |████████████████████████████████| 163 kB 2.0 MB/s 
Collecting django-contrib-comments>=1.9
  Downloading django_contrib_comments-2.1.0-py3-none-any.whl (406 kB)
     |████████████████████████████████| 406 kB 1.9 MB/s 
Collecting django>=2.2
  Downloading Django-4.0-py3-none-any.whl (8.0 MB)
     |████████████████████████████████| 8.0 MB 4.8 MB/s 
Collecting oauthlib>=3.0.0
  Downloading oauthlib-3.1.1-py2.py3-none-any.whl (146 kB)
     |████████████████████████████████| 146 kB 4.8 MB/s 
Collecting idna<4,>=2.5; python_version >= "3"
  Downloading idna-3.3-py3-none-any.whl (61 kB)
     |████████████████████████████████| 61 kB 4.6 MB/s 
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.7-py2.py3-none-any.whl (138 kB)
     |████████████████████████████████| 138 kB 4.3 MB/s 
Collecting certifi>=2017.4.17
  Downloading certifi-2021.10.8-py2.py3-none-any.whl (149 kB)
     |████████████████████████████████| 149 kB 3.5 MB/s 
Collecting charset-normalizer~=2.0.0; python_version >= "3"
  Downloading charset_normalizer-2.0.9-py3-none-any.whl (39 kB)
Collecting soupsieve>1.2
  Downloading soupsieve-2.3.1-py3-none-any.whl (37 kB)
Collecting packaging
  Downloading packaging-21.3-py3-none-any.whl (40 kB)
     |████████████████████████████████| 40 kB 3.9 MB/s 
Collecting six>=1.9.0
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting webencodings
  Downloading webencodings-0.5.1-py2.py3-none-any.whl (11 kB)
Collecting pytz-deprecation-shim
  Downloading pytz_deprecation_shim-0.1.0.post0-py2.py3-none-any.whl (15 kB)
Collecting backports.zoneinfo; python_version < "3.9"
  Downloading backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_x86_64.whl (74 kB)
     |████████████████████████████████| 74 kB 4.4 MB/s 
Collecting asgiref<4,>=3.4.1
  Downloading asgiref-3.4.1-py3-none-any.whl (25 kB)
Collecting sqlparse>=0.2.2
  Downloading sqlparse-0.4.2-py3-none-any.whl (42 kB)
     |████████████████████████████████| 42 kB 2.2 MB/s 
Collecting pyparsing!=3.0.5,>=2.0.2
  Downloading pyparsing-3.0.6-py3-none-any.whl (97 kB)
     |████████████████████████████████| 97 kB 2.3 MB/s 
Collecting tzdata; python_version >= "3.6"
  Downloading tzdata-2021.5-py2.py3-none-any.whl (339 kB)
     |████████████████████████████████| 339 kB 3.4 MB/s 
Installing collected packages: pillow, chardet, oauthlib, idna, urllib3, certifi, charset-normalizer, requests, requests-oauthlib, soupsieve, beautifulsoup4, pyparsing, packaging, six, webencodings, bleach, backports.zoneinfo, tzdata, pytz-deprecation-shim, tzlocal, filebrowser-safe, grappelli-safe, asgiref, sqlparse, django, django-contrib-comments, mezzanine
Successfully installed asgiref-3.4.1 backports.zoneinfo-0.2.1 beautifulsoup4-4.10.0 bleach-4.1.0 certifi-2021.10.8 chardet-4.0.0 charset-normalizer-2.0.9 django-4.0 django-contrib-comments-2.1.0 filebrowser-safe-1.0.0 grappelli-safe-1.0.0 idna-3.3 mezzanine-5.0.0 oauthlib-3.1.1 packaging-21.3 pillow-8.4.0 pyparsing-3.0.6 pytz-deprecation-shim-0.1.0.post0 requests-2.26.0 requests-oauthlib-1.3.0 six-1.16.0 soupsieve-2.3.1 sqlparse-0.4.2 tzdata-2021.5 tzlocal-4.1 urllib3-1.26.7 webencodings-0.5.1

The main part from the long paste above: Successfully installed ... django-4.0 ...

setup.cfg defines Django > 2.2 (https://github.com/stephenmcd/mezzanine/blob/v5.0.0/setup.cfg#L43) and as Django 4.0.0 was released 7.12.2021 (https://docs.djangoproject.com/en/4.0/releases/4.0/) that is the version that will get installed.

I already started adding support to Django 4.0.0 by making a small pr to filebrowser-safe here: stephenmcd/filebrowser-safe#136

I have other changes already that atleast get the project started with Django 4.0.0 but would like to see the first one checked before committing more time to this.

@skru
Copy link

skru commented Dec 19, 2021

Mezzanine is still using django.conf.urls in a few places in addition to filebrowser so I would hold off and stick with django3.2.10 as mezzanine5.0.0 has only just been released. (this is assuming you just want to get a site up and running).

Obviously pull requests, I'm sure are welcome to bring Django4 in

@tswfi
Copy link
Contributor Author

tswfi commented Dec 20, 2021

@skru yeah, I have a old site I want to upgrade and might as well take a few extra steps to get to the latest Django at the same time :D

filebrowser pr is done and tests are running, but the last step of CI looks like it tries to do a new release which obviously fails.

I'll try to get a similar pr to this repo in the near future.

@danlen
Copy link

danlen commented Dec 31, 2021

Yeah, mezzanine==5.0.0 installs django v 4.0. It works then installing django==3.2.10 Thanks

@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2022

🎉 This issue has been resolved in version 5.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants