我不太喜欢你的目录(结构)。
如果文件夹“web”是一个应用程序,“dedo”是一个具有设置的文件夹,则不能在应用程序文件夹中包含文件夹“static”和“templates”。
应该是:dedo
__init__.py
settings.py
urls.py
views.py
static
css
bootstrap.min.css
templates
base.html
index.html
web
migrations
__init__.py
admin.py
models.py
tests.py
views.py
db.sqlite3
manage.py
在settings.py中,您需要写下:STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
STATIC_URL=通过浏览器访问静态文件
static files\u DIRS=Django将在其中查找静态文件
重要:
如果要通过适当的web服务器(nginx,apache,…)和WSGI(gunicorn,modwsgi,…)部署web应用程序,则仅使用STATIC_ROOT=
“python manage.py collectstatic”或“python3.X manage.py collectstatic”是用于将静态文件从static files目录(加上/admin/的静态文件)复制到static目录的命令,这意味着static目录不能与STATICFILES目录相同。