[英]Django 3.0.7 unable to change STATIC_ROOT path
Hi I am new to django,嗨,我是 django 的新手,
I have created a django project with following urls.py and settings.py codes respectively我创建了一个 django 项目,分别具有以下 urls.py 和 settings.py 代码
urls.py网址.py
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('admin/', admin.site.urls),
path('',include("user_mgmt.urls")),
path('',include("dashboard.urls")),
]
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
settings.py设置.py
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR),"spaat_static")
then I am collecting the static files using:然后我使用以下方法收集 static 文件:
python manage.py collectstatic
but Django is collecting files in the ../staticfiles directory, whereas I have defined ../spaat_static in STATIC_ROOT.但是 Django 正在收集../staticfiles目录中的文件,而我在STATIC_ROOT中定义了 ../spaat_static。
How to solve this issue?如何解决这个问题?
Thank you in advance!先感谢您!
THIS LINE:这条线:
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR),"spaat_static")
Try to change it to:尝试将其更改为:
STATIC_ROOT = os.path.join(BASE_DIR,"spaat_static")
And tell me how it goes.告诉我进展如何。 Peace.
和平。
Don't forget to add this:)不要忘记添加这个:)
STATICFILES_DIRS = [
os.path.join(BASE_DIR,"spaat_static"),
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.