【发布时间】:2016-02-23 20:42:43
【问题描述】:
我在加载css文件时遇到问题,在调用继承了读取css页面的base_ownsite.html的index.html之后,css没有加载......
base_ownsite.html
{% load staticfiles %}
<!DOCTYPE html>
<html lang="en">
<head>
<title>{% block title %}{% endblock %}</title>
<link rel="stylesheet" type="text/css" href="{% static 'ownsite/css/style.css' %}" />
</head>
<body>
{% block content %}
{% endblock %}
</body>
</html>
index.html
{% extends 'ownsite/base_ownsite.html' %}
{% block content %}
{% if user.is_authenticated %}
<p>Jesteś zalogowany <a href='accounts/my_view'>{{ user.username }}</a></p>
<p><a href='/accounts/logout_view'>wyloguj</a></p>
{% else %}
<h2>Strona główna</h2>
<a href='/accounts/login_view'>logowanie</a>
<a href='/accounts/register_user'>rejestracja</a>
{% endif %}
{% endblock %}
style.css
body {
background: yellow;
}
h2 {
color: red;
}
p {
color: yellow;
}
settings.py
STATIC_URL = '/static/'
STATICFILES_DIRS = (
"/ownsite/static",
)
我添加了我的目录的打印屏幕
【问题讨论】:
-
代码中有一个空格(见下划线字符)
/css_/style -
Hmm in css 我在 "ownsite 有下划线,但我不知道为什么,没有任何空格:/...
标签: css django templates django-templates