你不能使用 MEDIA_ROOT 或 MEDIA_URL 这是上传的媒体而不是你的静态内容,你不需要设置 URL 模式,因为这仅适用于 django 1.2 或“如果你使用其他服务器进行本地开发”:https:/ /docs.djangoproject.com/en/dev/howto/static-files/#serving-static-files-in-development
你需要有你的静态文件:botstore/botstore/static/botstore/css.css
然后使用:
HOME_ROOT = os.path.dirname(__file__)
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = os.path.join(HOME_ROOT, 'staticfiles')
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/", "/static/admin/".
ADMIN_MEDIA_PREFIX = '/static/admin/'
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
然后在您的 HTML 中,您可以这样引用您的静态文件:
<link rel="stylesheet" type="text/css" href="{{ STATIC_URL }}botstore/css.css" />