gtalarico / django-vue-template

Django Rest + Vue JS Template
https://django-vue-template-demo.herokuapp.com/
MIT License
1.57k stars 406 forks source link

Whitenoise 4.0 breaks Django 3.0 #45

Open BenQuigley opened 4 years ago

BenQuigley commented 4 years ago

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 commented 4 years ago

yes you are right it worked for me

LQiTong commented 2 years ago

thanks alot, it worked for me