我正在制作“是新年页面”,该页面应该回答是或否,这不是问题,但这里的问题是我在
中编写此链接的链接一些细节:
应用程序名称是新年 我里面有一个名为 static/newyear 的文件夹 以及 newyear 文件夹内的 styles.css 文件
我没有尝试任何方法来解决它,因为只有这种链接方式 我刚刚删除了链接并尝试了很多次但仍然不起作用 代码:
{% load static %}
<Doctype html>
<html lang="en">
<head>
<title>Is it New Year?</title>
<link href="{% static 'newyear/styles.css' %}" rel="stylesheet">
</head>
<body>
{% if newyear %}
<h1>YES!</h1>
{% else %}
<h1> NO!!!</h1>
{% endif %}
</body>
</html>
如果你写“在服务器上”,并且它不是本地主机,我想,可能你需要应用 collectstatic django cli。
更多信息:https://docs.djangoproject.com/en/5.0/ref/contrib/staticfiles/