Warning about Django's STATIC_ROOT directory not found when WHITENOISE_USE_FINDERS is true
See original GitHub issueThanks for developing whitenoise 👍
I have a use case where I’d like whitenoise to transparently handle all the static files for a Django application. The amount of static files is minimal and gets little to no traffic.
Reproducing this particular issue should be fairly easy:
whitenoise.middleware.WhiteNoiseMiddleware
in the settings.pyMIDDLEWARE
listWHITENOISE_USE_FINDERS = True
in settings.py- Set
STATIC_ROOT
to a path that doesn’t exist yet (because Django creates this only when running collectstatic, which I’d actually like to avoid)
Running manage.py runserver
will raise a warning like this:
.tox/runserver/lib/python3.6/site-packages/whitenoise/base.py:104: UserWarning: No directory at: /var/www/static
warnings.warn(u'No directory at: {}'.format(root))
The warning isn’t a blocker: it doesn’t prevent runserver or a wsgi server from starting.
The warning might not be relevant when WHITENOISE_USE_FINDERS
is True
, though.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:10 (1 by maintainers)
Top Results From Across the Web
Django - Static file not found - Stack Overflow
I'm trying to serve static files within my Django 1.3 development environment. Here are my settings ... STATIC_ROOT = '/home/glide/Documents/django/cbox/static/ ...
Read more >Using WhiteNoise with Django
If your application is not running at the root of the domain and FORCE_SCRIPT_NAME is set then this value will be removed from...
Read more >Static Files in Django - Dan's Cheat Sheets's documentation!
To get the static files to the directory where your web server will look for them, you'll set STATIC_ROOT to that directory path,...
Read more >Warning about Django's STATIC_ROOT directory not found ...
Thanks for developing whitenoise :+1: I have a use case where I'd like whitenoise to transparently handle all the static files for a...
Read more >How to manage static files (e.g. images, JavaScript, CSS)
Store your static files in a folder called static in your app. ... by runserver when DEBUG is set to True (see django.contrib.staticfiles.views.serve()...
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
My
pytest
solution (just put it in yourconftest.py
):Unfortunately there’s no completely clean way of dealing with this. Ideally we’d set
STATIC_ROOT
to None as a way of signalling that we never intend to write anything to it and then WhiteNoise would ignore the setting. But Django throws an ImproperlyConfigured exception if you try to do that. So you have to set it to a filesystem path, and WhiteNoise then has no way of knowing that you intended the directory to be missing.Probably the easiest thing to do is to silence the warning by adding something like the following to you settings file: