Open edmorley opened 6 years ago
Thanks Ed, I hadn't considered this situation. I wonder if the correct behaviour would be just not to warn about missing directories if autorefresh
is enabled. What do you think?
Yeah I think skipping the warning entirely if autorefresh
enabled, might be the simplest thing :-)
Hi
I've just started a new project with Whitenoise 4.0 and have exactly this problem - will there be a release that removes this warning in local dev?
Thanks.
@urlsangel Yep, the 4.1 release should be out soon which will include this fix
@evansd
Great stuff, thanks for your work on this! 👍
@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?
I can confirm what @Br4nd0R is saying. This issue is still there in 5.2.0
Same here - 5.2.0 - I'm guessing a recent commit accidentally put it back in?
Still here in 6.2.
I noticed this while running tests locally.
This can be worked around either by:
./manage.py collectstatic
and having this dir exist before running tests.TEST_RUNNER
setting, and in that runner add the setting: WHITENOISE_AUTOREFRESH = True
As for why this warning is being triggered even though it was though to have been fixed:
WhiteNoise.add_files()
was changed late 2018 (after 4.1) from defining the root
directory as:
root = root.rstrip(os.path.sep) + os.path.sep
to its current:
root = os.path.abspath(root)
The difference between these in 3.11
is the current version returns the path without the final forward slash.
That said, the test of existence, os.path.isdir(root)
returns False for me either way (triggering a warning in each case).
The original commit merged in 4.1 seems to have included a test stub.
Currently, the test that should cover tests for the existence of a single warning.
I wonder if a warning is being issued but it isn't the one expected by the failed directory check
Hi! :-)
STR:
STATIC_ROOT
doesn't yet existDEBUG = True
, run./manage.py runserver
Expected:
No console warnings about a missing static files directory.
Actual:
Warning in the console:
Notes:
add_files()
in 2a883f5cda0336dbefebef7bb918c3a2b167a70d.STATIC_ROOT
directory, since:collectstatic
handles the creation of the directory automatically.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
.A possible solution might be to have
.add_files()
take an optionalignore_missing=False
argument, which is left asFalse
everywhere apart from the Django middleware static root usage. eg:That said, should
static_root
even be added when run inDEBUG
mode? The Django docs say not to place anything in theSTATIC_ROOT
directory directly, so it feels like there shouldn't be content there (though how many people go against that, I don't know).