Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python CSS在Django上的某些页面中不起作用_Python_Css_Django_Reference - Fatal编程技术网

Python CSS在Django上的某些页面中不起作用

Python CSS在Django上的某些页面中不起作用,python,css,django,reference,Python,Css,Django,Reference,我是Python和Django的初学者,一直在努力解决以下问题: 在localhost:8000/webiste上运行良好,但在localhost:8000/invoice/上某些引用不起作用。例如,CSS不起作用,但图像和JavaScript起作用 我使用相对链接指出我的路径所在 <script src="{% static "js/jquery.min.js" %}"></script> <script src="{% static "js/sk

我是Python和Django的初学者,一直在努力解决以下问题:

在localhost:8000/webiste上运行良好,但在localhost:8000/invoice/上某些引用不起作用。例如,CSS不起作用,但图像和JavaScript起作用

我使用相对链接指出我的路径所在

    <script src="{% static "js/jquery.min.js" %}"></script>
    <script src="{% static "js/skel.min.js" %}"></script>
    <script src="{% static "js/skel-layers.min.js" %}"></script>
    <script src="{% static "js/init.js" %}"></script>

    <noscript>
        <link rel="stylesheet" href="{% static "css/skel.css" %}"/>
        <link rel="stylesheet" href="{% static "css/style.css" %}"/>
        <link rel="stylesheet" href="{% static "css/style-xlarge.css" %}"/>
    </noscript>

    <img src="{% static "images/pic07.jpg" %}" alt="" />
View.py

def home(request):
  return render(request, 'principal.html',)

def invoice(request):
  return render(request, 'invoice.html',)
当我用浏览器检查页面代码时,我看到链接被称为

invoice.html位于/project/folder/templates/内,my.css位于/project/static/css/内。invoice.html位于同一文件夹my index.html(principal.html)页面中,该页面正在工作


此外,网站/发票/页面内的所有链接变为网站/发票/链接,而不是网站/链接

问题已解决,删除标签。此外,由于js文件引用其他css文件,控制台上出现404错误,我在模板中添加了一个变量,以包含url:

<script>
  var url = "{% static 'css/' %}";
</script>

var url=“{%static'css/'%}”;

在.js内部,我使用了url.concat('style.css')

什么css?您的示例实际上没有显示任何。。。请给出一个例子,事实上,您使用的是django框架,而不仅仅是“python”。invoice.html在哪里?invoice.html在project/folder/templates/中,my.css在/project/static/css/中。invoice.html与我的index.html页面位于同一文件夹中,该页面正在工作。我已删除标记,它工作正常。然而,我不知道为什么它对我的索引有效,而对发票无效。
<script>
  var url = "{% static 'css/' %}";
</script>