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

Whitenoise 4.0 breaks Django 3.0 #45

Open
BenQuigley opened this issue Dec 15, 2019 · 2 comments
Open

Whitenoise 4.0 breaks Django 3.0 #45

BenQuigley opened this issue Dec 15, 2019 · 2 comments

Comments

@BenQuigley
Copy link

BenQuigley commented Dec 15, 2019

Hi, this project's Pipfile specifies Python 3.6, which I don't have installed locally, so I thought I'd bump it to 3.7 for my project. (Edit: this may or may not be actually related; maybe if someone has 3.6 installed they can check).

The Pipfile also specifies django = "*" (so Django 3.0 got installed) and whitenoise = "==4.0". However, whitenoise 4 is apparently not compatible with Django 3, because it tries to import from django.utils.six, which I guess has gone away in Django 3 (before, after). This resulted in errors like:

Exception in thread django-main-thread:
Traceback (most recent call last):
File "/home/ben/.local/share/virtualenvs/my-env-heqyJ-0V/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 45, in get_internal_wsgi_application
return import_string(app_path)
File "/home/ben/.local/share/virtualenvs/my-env-heqyJ-0V/lib/python3.7/site-packages/django/utils/module_loading.py", line 17, in import_string
module = import_module(module_path)
File "/home/ben/.local/share/virtualenvs/my-env-heqyJ-0V/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/ben/local/my-env/backend/wsgi.py", line 18, in <module>
application = get_wsgi_application()
File "/home/ben/.local/share/virtualenvs/my-env-heqyJ-0V/lib/python3.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
return WSGIHandler()
File "/home/ben/.local/share/virtualenvs/my-env-heqyJ-0V/lib/python3.7/site-packages/django/core/handlers/wsgi.py", line 127, in __init__
self.load_middleware()
File "/home/ben/.local/share/virtualenvs/my-env-heqyJ-0V/lib/python3.7/site-packages/django/core/handlers/base.py", line 35, in load_middleware
middleware = import_string(middleware_path)
File "/home/ben/.local/share/virtualenvs/my-env-heqyJ-0V/lib/python3.7/site-packages/django/utils/module_loading.py", line 17, in import_string
module = import_module(module_path)
File "/home/ben/.local/share/virtualenvs/my-env-heqyJ-0V/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/ben/.local/share/virtualenvs/my-env-heqyJ-0V/lib/python3.7/site-packages/whitenoise/middleware.py", line 10, in <module>
from django.utils.six.moves.urllib.parse import urlparse
ModuleNotFoundError: No module named 'django.utils.six'

Whitenoise 5 is out, so this seemed to fix the problem for my purposes:

--- a/Pipfile
+++ b/Pipfile
@@ -7,11 +7,11 @@ name = "pypi"
 django = "*"
 djangorestframework = "*"
 gunicorn = "*"
-whitenoise = "==4.0"
+whitenoise = ">=5"
 dj-database-url = "*"
 psycopg2-binary = "*"
 
 [dev-packages]
 
 [requires]
-python_version = "3.6"
+python_version = "3.7"

Or alternatively you could specify Django 2.2 if you don't want to bump the Python and the Django versions.

@shadmaan4f93
Copy link

yes you are right it worked for me

@LQiTong
Copy link

LQiTong commented Aug 8, 2022

thanks alot, it worked for me

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

No branches or pull requests

3 participants