Why does this code have this error: "Expected:)"?
I am getting an error from Aptana "Expected:)" on this code at the return render_to_response
line after the final else:
. I can't for the life of me figure out why that is, because as far as I can tell I have closed all of my parentheses. I'm guessing that it is actually some other error and Aptana (Eclipse branch) is just not smart enough to give me the actual error. When I attempt to load a webpage using another view in this file, it tells me only that it is a Syntax Error.
def login(request):
if request.method == 'Post':
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
if user is not None:
if user.is_active:
login(request, user)
return HttpResponseRedirect('/')
else:
#return a 'disabled account' error message
return HttpResponseRedirect('/disabled_account/')
else:
return render_to_response('login.html', {
'failed_login' : True,
'form' : AuthenticationForm()
},
context_instance=RequestContext(request),
)
else:
return render_to_response('login.html' {
'failed_login' : False,
'form' : AuthenticationForm()
},
context_instance=RequestC开发者_运维技巧ontext(request),
)
There's a comma missing after 'login.html' in the else: section
You're missing a comma after the template name in the final return line. You have:
return render_to_response('login.html' {
'failed_login' : False,
'form' : AuthenticationForm()
},
context_instance=RequestContext(request),
)
But it should be:
return render_to_response('login.html', {
'failed_login' : False,
'form' : AuthenticationForm()
},
context_instance=RequestContext(request),
)
精彩评论