Django告诉我,我的原木认为是一只HttpResponse物体返回的:
The view accounts.views.login didn t return an HttpResponse object.
然而,使用<代码>render_to_response()的Im,在不做出答复的情况下,这种观点根本无法解决。 该法典:
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})
我确信,这部法典可以提高效率(无助),但这应当行之有效?