我是新手Django
,需要一些有关login
表格的帮助。这就是我所做的。
我的模板有index.html
<form class="form-signin" action="/login" method="post">
{% csrf_token %}
<h2 class="form-signin-heading">Please sign in</h2>
<input type="text" class="input-block-level" placeholder="Email address" name="email">
<input type="password" class="input-block-level" placeholder="Password" name="password">
<label class="checkbox">
<input type="checkbox" value="remember-me"> Remember me
</label>
<button class="btn btn-large btn-primary" type="submit">Sign in</button>
</form>
& home.html
as {{user.username}}
(仅此行用于测试)
我的views.py
有:
def login(request):
s_email = request.POST["email"]
s_password = request.POST["password"]
global user
user = authenticate(email=s_email, password=s_password)
if user is not None:
if user.is_active:
login(request, user)
return render_to_response('home.html', dict(user=user), RequestContext(request))
else:
return render_to_response('index.html', {}, RequestContext(request))
我的urls.py
有:
url(r'^/login/$', 'website.views.login')
尽管如此,我还是无法登录。404
每当我单击 HTML 按钮"Sign In"
到.
需要帮忙。