我正在努力加载我的 custom.css 文件以在我的 Bootstrap 模板中使用:
错误:
"GET /static/artdb/css/custom.css HTTP/1.1" 404 1785
custom.css 路径:
static/artdb/css/custom.css
基础.html:
{% load static %}
:
<!-- Custom styles for this template -->
<link rel="stylesheet" href="{% static "artdb/css/custom.css" %}">
urls.py:
urlpatterns = [
path('artdb/', include('artdb.urls')),
path('admin/', admin.site.urls),
]+static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
设置.py:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR,'static')
#STATICFILES_DIRS =(os.path.join(BASE_DIR,"static"),)
知道哪里出了问题吗?
最佳答案
设置.py:
STATIC_URL = '/static/'
STATIC_ROOT= os.path.join(os.path.dirname(BASE_DIR),'static')
STATICFILES_DIRS= [os.path.join(BASE_DIR,'###path to static folder in project###'),STATIC_URL]
关于css - django css 文件未加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52590583/