django将%2F添加到url标记

时间:2014-09-17 22:16:19

标签: django django-templates

django 1.6,python 2.7 我有这个网址

url(r'^index/$', 'baseball.views.home', name='home'),

和这个模板:

href="{% url "home" %}">Baseball Statistics</a></h1>

我得到这个网址:

http://localhost:8000/%2Findex/

我在url标签上尝试过安全,但没有区别。该链接有效,但看起来很奇怪。我怎么能纠正这个?

1 个答案:

答案 0 :(得分:1)

有一个类似的问题,但由于我添加了一个斜杠,如下所示:

url(r'^/index/$', 'baseball.views.home', name='home')

在开头删除斜杠可以解决问题:

url(r'^index/$', 'baseball.views.home', name='home')