UWSGI and Whitenoise
See original GitHub issueHello,
I am running 2 docker containers: 1) nginx proxy and 2) uwsgi with my django 1.8 app. I have to solve the static files issue since nginx normally handles the static files so I found whitenoise. I followed the simple howto and changed my wsgi.py:
import os
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "ironman.settings")
#os.environ("DJANGO_SETTINGS_MODULE", "ironman.settings")
application = get_wsgi_application()
application = DjangoWhiteNoise(application)
and my settings.py:
WSGI_APPLICATION = 'ironman.wsgi.application'
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
And I loaded the staticcontent app:
'django.contrib.staticfiles',
The error I am getting from UWSGI:
Traceback (most recent call last):
File "./ironman/wsgi.py", line 13, in <module>
from whitenoise.django import DjangoWhiteNoise
File "/usr/local/lib/python2.7/dist-packages/whitenoise/django.py", line 14, in <module>
from django.contrib.staticfiles.storage import staticfiles_storage
File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/storage.py", line 12, in <module>
from django.core.cache import (
File "/usr/local/lib/python2.7/dist-packages/django/core/cache/__init__.py", line 34, in <module>
if DEFAULT_CACHE_ALIAS not in settings.CACHES:
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 48, in __getattr__
self._setup(name)
File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 42, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting CACHES, but settings are not configured. You must either define the environment variable DJANGO_SETTING
S_MODULE or call settings.configure() before accessing settings.
I’ve tried setting the CACHES and DEFAULT_CACHE_ALIAS in my settings.py but to no effect.
What am I doing wrong?
Thanks for all the help.
Michiel
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Using WhiteNoise with any WSGI application
WhiteNoise comes with a command line utility which will generate compressed versions of your files for you. Note that in order for brotli...
Read more >Serving static files with uWSGI (updated to 1.9) - Read the Docs
Generally your webserver of choice (Nginx, Mongrel2, etc.) will serve static files efficiently and quickly and will simply forward dynamic requests to uWSGI...
Read more >How to setup wsgi.py file in Django for WhiteNoise 5.1.0?
I've got that i need to setup wsgi.py file for WhiteNoise. I tried some different ways which i found to setup it but...
Read more >How to run uWSGI - ionel's codelog
Given the cornucopia of options uWSGI offers it's really hard to ... Either run python -m whitenoise.compress or use this Django setting:.
Read more >You too struggle with static files ? You don't know Whitenoise ...
They proxy dynamic requests to it with a web server. The uWSGI http implementation is pretty new and I wouldnt really start trusting...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think the problem here is that you need the line:
to come at the top of the
wsgi.py
file, before you importDjangoWhiteNoise
.Oh I see. That sounds good. Sorry for blaming wn. 😃