question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Warning shown if STATIC_ROOT directory missing in development

See original GitHub issue

Hi! 😃

STR:

  1. Update existing Django+WhiteNoise project from whitenoise 3.3.1 to 4.0.
  2. Don’t run collectstatic (ie since developing locally), so the directory referenced by STATIC_ROOT doesn’t yet exist
  3. 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 causes collectstatic to output misleading warnings/prompts about overwriting existing files) or else have additional local setup steps prior to running ./manage.py runserver.

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:open
  • Created 5 years ago
  • Reactions:3
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
kirankumbharcommented, Feb 15, 2021

I can confirm what @Br4nd0R is saying. This issue is still there in 5.2.0

3reactions
TheBitShepherdcommented, Jan 8, 2021

@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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found