为什么不在某些图片中启动css? 我的settings.py:
ROOT = os.path.dirname(os.path.abspath(__file__))
cd = lambda *a: os.path.join(ROOT, *a)
PROJECT = os.path.basename(ROOT)
MEDIA_ROOT = cd('public/uploads')
MEDIA_URL = '/uploads/'
STATIC_ROOT = cd('public/assets')
STATIC_URL = '/assets/'
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
我的模板.html:
<link href="{{ STATIC_URL }}themes/css/bootstrappage.css" rel="stylesheet"/>
答案 0 :(得分:1)
一旦确定路径正确,您将需要在模板中使用正确的格式,Django团队推荐的最后一种格式是:
{% load staticfiles %}
<img src="{% static "my_app/myexample.jpg" %}" alt="My image"/>
<link href="{% static "themes/css/bootstrappage.css" rel="stylesheet"/>
查看documentation on static files from djangoproject.com的完整步骤和详细信息。