我正在编写一个包含用户注册和登录功能的应用程序。成功登录/注册操作后,用户将被重定向到user.html
现在,整个 HTML 文本显示为 URL 参数,这会引发错误 404
我用于视图处理的视图代码:
def index(request):
return render(request, "app/index.html")
def user(request):
return render(request, "app/user.html")
def userLogin(request):
print "Loggin In!"
loginUser = authenticate(username = request.POST["username"], password = request.POST["password"])
print loginUser.username
print loginUser.is_staff
if loginUser is not None:
if loginUser.is_active:
login(request, loginUser)
return HttpResponseRedirect(reverse(user))
和我的网址:
urlpatterns = patterns("",
url(r'^$', views.index, name = "index"),
url(r'^user/$', views.user),
url(r'^registerNewUser/$', views.registerNewUser),
url(r'^userLogin/$', views.userLogin),
)
在重定向时,这是显示的消息:
Django tried these URL patterns, in this order:
^admin/
^app/ ^$ [name='index']
^app/ ^user/$
^app/ ^registerNewUser/$
^app/ ^userLogin/$
The current URL, app/<html><head><title>User Landing Page</title><link rel = "stylesheet" type = "text/css" href = "/static/css/jquery-ui.min.css" ><link rel = "stylesheet" type = "text/css" href = "/static/css/main.css"><script type = "text/javascript" src = "/static/js/jquery.js"></script><script type = "text/javascript" src = "/static/js/jquery-ui.min.js"></script><script type = "text/javascript" src = "/static/js/jquery.cookie.js"></script><script type = "text/javascript" src = "/static/js/csrfSetup.js"></script></head><body>User is logged</body></html>, didn't match any of these.
为了在成功登录时呈现 HTML,我需要做什么?