Django网址/观点

时间:2018-03-02 03:47:10

标签: python django url views

我不知道为什么我的代码不起作用?我正在尝试返回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

1 个答案:

答案 0 :(得分:0)

尝试删除/&amp;来自detais / id url并替换为/ $

更改

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

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