我正在django中尝试此代码:该urls.py有:re_path(r'^(?P<site_url_var>[-\w.]+)/$', views.FnDetails, name='detail'),该views.py有:def FnDetails(request, site_url_var): try: url_details = detail.objects.get(page_end_url=site_url_var) except detail.DoesNotExist: raise Http404("Url Does Not Exist") return render(request, 'base.html', {'url_details' : url_details})但是在某些情况下,如果其他值存在url.py,则会返回HTTP 404错误。我想要的是类似以下内容的东西:except: redirect("to Other View")
添加回答
举报
0/150
提交
取消