[英]Link static/css file with Django template
I am pretty new to Django and I am trying to link CSS file with my HTML document and I have tried using all possible ways posted on StackOverflow and I am unable to locate what is the issue here.我对 Django 很陌生,我正在尝试将 CSS 文件与我的 HTML 文档链接起来,我已经尝试使用 StackOverflow 上发布的所有可能方式,但我无法找到问题所在。
Here is the directory and file structure:这是目录和文件结构:
settings.py设置.py
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, '/')
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static"),
)
index.html索引.html
{% load static %}
<link rel="stylesheet" type="css/text" href="{% static 'css/style.css' % }">
Thanks in advance.提前致谢。
Ops.行动。 Silly mistake.
愚蠢的错误。 It was all about indentation and minor
type
tag changes.这完全是关于缩进和较小的
type
标签更改。 Here is what worked out for me.这对我有用。
{% load static %}
<link rel="stylesheet" type="text/css" href="{% static 'css/style.css' %}">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.