Warning shown if STATIC_ROOT directory missing in development
See original GitHub issueHi! 😃
STR:
- Update existing Django+WhiteNoise project from whitenoise 3.3.1 to 4.0.
- Don’t run collectstatic (ie since developing locally), so the directory referenced by
STATIC_ROOT
doesn’t yet exist - With Django’s
DEBUG = True
, run./manage.py runserver
Expected:
No console warnings about a missing static files directory.
Actual:
Warning in the console:
...
Django version 1.11.15, using settings 'treeherder.config.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
/usr/local/lib/python2.7/site-packages/whitenoise/base.py:97: UserWarning: No directory at: /app/treeherder/static/
warnings.warn(u'No directory at: {}'.format(root))
Notes:
- The warning was added to
add_files()
in 2a883f5cda0336dbefebef7bb918c3a2b167a70d. - We don’t pre-create the
STATIC_ROOT
directory, since:- Django’s
collectstatic
handles the creation of the directory automatically - To create the directory we’d either need to use the
.gitkeep
type approach (which then causescollectstatic
to output misleading warnings/prompts about overwriting existing files) or else have additional local setup steps prior to running./manage.py runserver
.
- Django’s
A possible solution might be to have .add_files()
take an optional ignore_missing=False
argument, which is left as False
everywhere apart from the Django middleware static root usage. eg:
if self.static_root:
self.add_files(self.static_root, prefix=self.static_prefix, ignore_missing=self.autorefresh)
That said, should static_root
even be added when run in DEBUG
mode? The Django docs say not to place anything in the STATIC_ROOT
directory directly, so it feels like there shouldn’t be content there (though how many people go against that, I don’t know).
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Django - Static file not found - Stack Overflow
On running the above 'findstatic' command if Django shows you this path then just paste all your static files in this static directory....
Read more >Trouble debugging static files not working with the local server ...
My issue is fairly simple: when doing ./manage.py runserver localhost:8080 none of the files in my static directory are being served, which is ......
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 >Configuration - MkDocs
If the 'root' of the MkDocs site will be within a subdirectory of a domain, ... The path from the base repo_url to...
Read more >docusaurus.config.js
For example, if your favicon is in static/img/favicon.ico : ... path : Root folder that all plugin localization folders of this locale are ......
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 can confirm what @Br4nd0R is saying. This issue is still there in 5.2.0
@evansd - I’m using version 5.2.0 and still seeing this warning, is there something that I need to set on my end to eliminate this?