Django css file is not working
42 观看
1回复
154 作者的声誉
I'm new in Django and get problem. I have:
STATIC_URL = '/static/'
STATIC_ROOT = '/static/'
at my settings.py, have Project/mainapp/static folder and css/header.css inside that folder. Also i have
{% load staticfiles %}
<link rel="stylesheet" href="{% static 'css/header.css' %}" type="text/css">
at my header html. Browser tries localhost/static/css/header.css but find nothing there. What am i doing wrong? Thanks!
作者: D. Make 的来源 发布者: 2017 年 12 月 27 日回应 1
1像
2995 作者的声誉
Define STATICFILES_DIRS
in your settings as below:
STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'), )
BASE_DIR
is global variable you can find in same settings.py which points to project's working directory. static
is your folder inside root directory of your app.
And load static
in template instead of staticfiles
like below:
{% load static %}
作者: Gahan
发布者: 2017 年 12 月 27 日
来自类别的问题 :
- html 如何检测网页中使用了哪一个定义的字体?
- html 如何为我的网站提供iPhone的图标?
- html 如何在Web表单字段/输入标记上禁用浏览器自动完成?
- html 如何使用Prototype自动调整textarea?
- html 如何定制有序列表中的数字?
- html 使用JavaScript滚动溢出的DIV
- css 使用CSS创建圆角
- css 如何在网站中找到未使用的图像和CSS样式?
- css 如何让页脚停留在网页的底部?
- django 以自定义形式使用Django时间/日期小部件
- django Fedora Core 9上的Django + FCGID - 我错过了什么?
- django django中的脏字段
- django 有没有简单的方法从CharField填充SlugField?
- django 在request.GET中捕获url参数
- django 型号limit_choices_to = {'用户':用户}