链接参数显示为HTML,而不仅仅是值

时间:2018-08-14 20:22:39

标签: django django-models django-forms django-templates django-2.0

当我为带有参数的链接构造URL时,链接地址中的参数值显示为HTML形式而不是值。

这是我在模板中生成链接的方式:

<a class="btn btn-success btn-block" href="{% url 'facility_page' facility_id=facility.id %} "  role="button">Edit</a>

链接地址的显示方式如下:

http://127.0.0.1:8000/facility/(%3FP%3Cinput%20type=%22hidden%22%20name=%22facility-0-id%22%20value=%221%22%20id=%22id_facility-0-id%22%3E%5B0-9%5D+)/

我希望链接看起来像这样:

http://127.0.0.1:8000/facility/1

我在这里做什么错了?

urls.py

# path('facility/<int:facility_id>/', facility, name='facility_page'),
path('facility/<int>/', facility, name='facility_page'),

0 个答案:

没有答案