I'm working on a Django project and the following error showed up
TypeError at /log_in/
'method' object is not subscriptable
Request Method: POST
Request URL: http://127.0.0.1:8000/log_in/
Django Version: 1.8.4
Exception Type: TypeError
Exception Value:
'method' object is not subscriptable
Exception Location: D:\pfd\recom\views.py in log_in, line 95
Python Executable: C:\Python34\python.exe
Python Version: 3.4.3
Python Path:
['D:\\pfd',
'C:\\Python34\\lib\\site-packages\\virtualenv-13.1.2-py3.4.egg',
'C:\\Windows\\SYSTEM32\\python34.zip',
'C:\\Python34\\DLLs',
'C:\\Python34\\lib',
'C:\\Python34',
'C:\\Python34\\lib\\site-packages']
Server time: Thu, 1 Oct 2015 22:34:00 +0530
and below is my log_in def
def log_in(request):
context = RequestContext(request)
if request.method == 'POST':
username = request.POST.get['username','']
password = request.POST.get['password','']
user = auth.authenticate(username=username, password=password)
if user is not None:
if user.is_active:
auth.login(request,user)
return HttpResponseRedirect('/loggedin/')
else:
return HttpResponse("Inactive user.")
else:
return HttpResponseRedirect('error.html')
return render_to_response('error.html')
Can't understand what's wrong.
Changed request.method to request.POST. When deleting context the post is not getting detected, only last statement gets executed.
When trying to delete request.method the same error shows up. Please help...
line 95?