Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/287.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 Django会自动将超链接url附加到现有url_Python_Django - Fatal编程技术网

Python Django会自动将超链接url附加到现有url

Python Django会自动将超链接url附加到现有url,python,django,Python,Django,我是django的初学者,目前我有一个url问题 例如,在我们的base.html页面中,我们硬编码了一些超链接标签,如,如果我们尝试从其他页面导航到此页面,如localhost:8000/shop_online.html/category/jewelry,然后单击超链接,我们将重定向到主页,但url如下所示:localhost:8000/shop\u online.html/category/jewelry/index.html 我认为这与url.py和硬编码的超链接标签有关,但我感到困惑,不

我是django的初学者,目前我有一个url问题

例如,在我们的
base.html
页面中,我们硬编码了一些超链接标签,如
,如果我们尝试从其他页面导航到此页面,如
localhost:8000/shop_online.html/category/jewelry
,然后单击超链接,我们将重定向到主页,但url如下所示:
localhost:8000/shop\u online.html/category/jewelry/index.html


我认为这与url.py和硬编码的超链接标签有关,但我感到困惑,不知道如何解决这个问题,我认为这是一个相当容易的问题

您应该在
href
属性中添加
/

<a href="/home.html">home</a>
这里有一个关于的文档


还有一件事:你不需要在你的url中有这个
*.html
扩展名。

谢谢你,用斜杠,问题马上解决了,我将把硬编码的url替换到url标签中。非常感谢你!
<a href="{% url index %}">home</a>