django认证错误

时间:2018-03-05 16:39:37

标签: python django url views

我遇到了一个错误,我正在登录用户,它应该重定向到details.html,但是url会被解析,但它会保留在login.html。我相信views.py存在问题。如果有更好的方法,请告诉我。感谢

views.py

@login_required(login_url="http://127.0.0.1:8000/accounts/login/")
def patientDetails(request, personalInfo_id):
current_user = request.user
if personalInfo_id == current_user.id:
    return render(request, 'personalInfo/details.html', {})
else:
    return render(request, 'personalInfo/login.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)

urls.py

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),
]

Picture of what is going wrong

0 个答案:

没有答案