帮助解决404错误:
--project
----templates
----project
------urls.py
------settigns.py
----app
----static
------css
------js
------images
--media
--static (after collectstatic command)
图像和js文件加载良好但不加载css文件。我不知道为什么。
我的项目结构:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static")
Settigns.py包含'django.contrib.staticfiles'
settings.py
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urls.py
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static 'css/design.css' %}"/>
<img src="{% static 'images/slide1.jpg' %}">
base.html文件
this.service.doRefresh();