|
发表于 2023-4-20 18:01:40
|
显示全部楼层
跳转网页传递参数,但是传的参数是IP,另一个例子传的是数字就不会报错
错误代码
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/ip/10.116.4.247/edit/
Using the URLconf defined in bysms.urls, Django tried these URL patterns, in this order:
ip/list/
ip/<int:nid>/edit/
The current path, ip/10.116.4.247/edit/, didn’t match any of these.
You’re seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
部分代码
HTML的
<a class="btn btn-primary btn-xs" href="/ip/{{ obj.ip_address }}/edit/">修改信息</a>
urls的
path('ip/<int:nid>/edit/', views.ip_edit),
views的
def ip_edit(request, nid):
if request.method == "GET":
row_object = models.ipinfo.objects.filter(ip_address=nid).first()
return render(request, "ip_edit.html", {"row_object": row_object})
求大佬解答谢谢
|
|