Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django WhiteNoise configuration is incompatible with WhiteNoise v4.0

Tags:

python

django

I am trying to deploy my Django webapp on Heroku. I have been facing this same error everytime I try to deploy.

ImportError: Your WhiteNoise configuration is incompatible with WhiteNoise v4.0 This can be fixed by following the upgrade instructions at: http://whitenoise.evans.io/en/stable/changelog.html#v4-0 ! Error while running '$ python manage.py collectstatic --noinput'. See traceback above for details. You may need to update application code to resolve this error. Or, you can disable collectstatic for this application: $ heroku config:set DISABLE_COLLECTSTATIC=1 https://devcenter.heroku.com/articles/django-assets ! Push rejected, failed to compile Python app. ! Push failed

I visited the link to make the changes as the documentation suggests. It required me to remove any mention from the the wsgi.py file and I had to add it to the middleware in settings.py and change the static storage.

#settings.py
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
.
.
.
.
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

I am following this tutorial (https://simpleisbetterthancomplex.com/tutorial/2016/08/09/how-to-deploy-django-applications-on-heroku.html)

I'm not sure what is causing this error. Whitenoise updates are applied and the static files are in place as well.

The project works like a charm on local server but im just not able to deploy it. Thanks in advance!

like image 375
Umang Mistry Avatar asked Apr 23 '19 14:04

Umang Mistry


People also ask

How do I use WhiteNoise in Django?

Using WhiteNoise in development You can disable Django's static file handling and allow WhiteNoise to take over simply by passing the --nostatic option to the runserver command, but you need to remember to add this option every time you call runserver . An easier way is to edit your settings.py file and add whitenoise.

What is WhiteNoise Python?

Radically simplified static file serving for Python web appsWith a couple of lines of config WhiteNoise allows your web app to serve its own static files, making it a self-contained unit that can be deployed anywhere without relying on nginx, Amazon S3 or any other external service.


1 Answers

whitenoise.django.GzipManifestStaticFilesStorage

alias has now been removed. Instead you should use the correct import path:

whitenoise.storage.CompressedManifestStaticFilesStorage

Source Link

like image 68
Mayank Soni Avatar answered Oct 26 '22 01:10

Mayank Soni