Problem applying css in Django with static-files app

自古美人都是妖i 提交于 2019-12-02 11:34:53

My style.css is located in .../Templates/site_media/static/css

doesnt match

<link href="{{STATIC_URL}}css/style.css" rel="stylesheet" type="text/css" >

you would need to have your link as:

<link href="{{STATIC_URL}}static/css/style.css" rel="stylesheet" type="text/css" >

Edit Use absolute paths for STATICFILES_DIRS (thx Yuji):

settings.py:

import os
SITE_ROOT = os.path.dirname(os.path.realpath(__file__))

STATIC_URL = '/static/'
STATICFILES_DIRS = ((os.path.join(SITE_ROOT,'Templates/site-media'),)

make sure that your:

TEMPLATE_CONTEXT_PROCESSORS has 'django.core.context_processors.static',

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!