0
Django是告訴我,我的登錄視圖沒有返回HttpResponse對象:如果我使用render_to_response,是否需要有一個HttpRequest對象?
The view accounts.views.login didn't return an HttpResponse object.
不過,我使用render_to_response()
到處是沒有辦法的視圖可以完成解決沒有得到響應。這裏的代碼:
def login(request):
if request.method == 'POST':
form = LoginForm(request.POST)
if form.is_valid():
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
if user is not None:
if user.is_active:
auth_login(request, user)
render_to_response('list.html')
else:
error = "It seems your account has been disabled."
render_to_response('list.html', {'error': error})
else:
error = "Bad login information. Give it another go."
render_to_response('list.html', {'error': error})
else:
error = "Bad login information. Give it another go."
render_to_response('list.html', {'error': error})
else:
error = "Whoa, something weird happened. You sure you're using the form on our site?"
render_to_response('list.html', {'error': error})
我敢肯定代碼可以更有效率(少渲染),但這應該工作,更正嗎?
*嘆*,我需要得到更多的睡眠。非常感謝你,我很抱歉浪費你的時間。 – n0pe 2012-04-26 22:13:06