Django网址/观点

问题描述 投票:0回答:1

我不知道为什么我的代码不起作用?我正在尝试返回user_id,将其解析为url,然后使用该user_id打开details.html。我意识到这可能不是最有效的方法。任何建议和帮助表示赞赏。

As you can see from this image the first redirect works but it says there are no matching patterns.

@login_required(login_url="http://127.0.0.1:8000/accounts/login/")
def patientDetails(request):
return render(request, 'personalInfo/details.html', {})
@login_required(login_url="http://127.0.0.1:8000/accounts/login/")
def after_login(request):
return HttpResponseRedirect('/personalInfo/details/%d/'%request.user.id)

urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^details/$', views.after_login, name='patient'),
url(r'^details/(?P<personalInfo_id>[0-9]+)/&', views.patientDetails),
]

New Error. Tried a few different ways of referencing id such as user_id and

python django url views
1个回答
0
投票

尝试删除/和details / id url并替换为/ $

更改

url(r'^details/(?P<personalInfo_id>[0-9]+)/&', views.patientDetails),

url(r'^details/(?P<personalInfo_id>[0-9]+)/$', views.patientDetails),
© www.soinside.com 2019 - 2024. All rights reserved.