【发布时间】:2021-03-23 11:59:51
【问题描述】:
我需要删除“?”在我的网址末尾:
urls.py
urlpatterns = [path("map_fslis_top/totals/<int:fstype_id>", views.edit_totals, name="edit_totals"),]
view.py
def edit_totals(request, fstype_id):
# Some code...
return render(request, "DataMech/totals.html", {
'fstype': fstype,
'typefslis': typefslis,
'totals': totals,
})
html 触发器
<button href="{% url 'edit_totals' fstype_id=fstype.id %}" class="btn btn-primary" class="form-control" type="submit" value="submit">Totals</button>
生成页面的网址:http://127.0.0.1:8000/map_fslis_top/totals/1?
我该如何摆脱那个丑陋的“?”在 URL 的末尾?
【问题讨论】:
-
您可以在 url 格式的末尾添加一个美元符号 -
<int:fstype_id>$
标签: django django-urls