mirror of
https://github.com/retspen/webvirtcloud.git
synced 2026-04-26 16:05:58 +03:00
[GH-ISSUE #605] if set DEBUG = True, run 'python3 manage.py collectstatic --noinput' error. #356
Labels
No labels
bug
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/webvirtcloud#356
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @smallpize on GitHub (Sep 25, 2023).
Original GitHub issue: https://github.com/retspen/webvirtcloud/issues/605
if set DEBUG = True, run 'python3 manage.py collectstatic --noinput' error.
ERROR: django.core.exceptions.ImproperlyConfigured: You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.
something wrong with:
STATIC_URL = "/static/"
if not DEBUG:
STATIC_ROOT = Path.joinpath(BASE_DIR, "static")
else:
STATICFILES_DIRS = [
Path.joinpath(BASE_DIR, "static"),
]
@krejcar25 commented on GitHub (Sep 25, 2023):
Hi smallpize,
does using
python3 manage.py collectstatic --noinput --settings=webvirtcloud.settings-devhelp?@MisterBlueBear commented on GitHub (Oct 23, 2023):
I am getting the same error message as smallpize. I am using Debian 11 with python 3.9.2
If I use the command "python3 manage.py collectstatic --noinput --settings=webvirtcloud.settings-dev", I get:
@krejcar25 commented on GitHub (Oct 23, 2023):
Hi, in this case, you are missing some packages. There is a dev requirements.txt file in the
devfolder. You'd want to dopip install -r dev/requirements.txtto setup your development environment. This should not be done in production though.@krejcar25 commented on GitHub (Oct 23, 2023):
@smallpize If my previous tip worked, please consider closing this issue, thank you!
@MisterBlueBear commented on GitHub (Oct 26, 2023):
I ran the
pip install -r dev/requirements.txtand it fixes theModuleNotFoundError: No module named 'debug_toolbar'error.However, when I run
python3 manage.py collectstatic --noinput --settings=webvirtcloud.settings-dev, I still get the same error.Shouldn't STATIC_ROOT be defined regardless if we are using debug or not ?
@krejcar25 commented on GitHub (Oct 26, 2023):
@MisterBlueBear as you can see in settings.py.template
STATIC_ROOTwill be set unlessDEBUGis enabled in settings.py. Do you perhaps still have that set from before? If you do, please setDEBUGtoFalsein settings.py.I don't know why it its done this way, maybe @catborise could explain it but that's the way I understand the code now.
@MisterBlueBear commented on GitHub (Oct 27, 2023):
When I set Debug to False, there is no issue. However, in this case, I wanted to turn on Debug in order to troubleshoot an issue. Whether Debug is True or False,
STATIC_ROOTshould be set.Also, these references state that the
static_rootshould not be instaticfiles_dirshttps://stackoverflow.com/a/27213753
https://stackoverflow.com/a/12161409
Seeing that django.contrib.staticfiles has this check:
And according to the django 4.2 docs for STATIC_ROOT
So the static files that are currently in the
static_root(i.e./static) should, by django 4.2 standards, be elsewhere and that other location is defined in STATICFILES_DIRS. In such, this allowscollectstaticto collects static files from all/staticsub-directories and dirs defined in STATICFILES_DIRS.Especially if you try to run collectstatic --clear option in order to remove stale static files. As of right now, I would loose all static files. I would use
--clearafter running in debug in order to remove the static files fordebug_toolbar.All this leads me to believe that current code below is not correct. At least in django 4.2
Instead, this would be the answer where the static files are stored in webvirtcloud/static/ for example.
So whether you are running in debug or not, there is no exception as STATIC_ROOT is always defined.
P.S. I'm not a django expert by any means, so let me know if I am wrong.