I am using the following code to login, but later when I navigate from index.html and try to access the get_profile() it says the id is not associated. But when I print the following variables both are false. What am I doing wrong here?
EDIT
def someotherview(request):
logging.debug(request.user.is_authenticated()) #prints false
logging.debug(request.user.is_active) #prints false
This is how the login
def logon(request):
qd = get_request_type(request)
try:
uname = qd.__getitem__('username')
pwd = qd.__getitem__('password')
user = authenticate(username = uname, password = pwd)
if user is not None:
response_dict.update({'yes':1})
logging.debug("labs_home1 ==================")
return render_to_response('home/index.html', context_instance=RequestContext(request, {'response_dict':response_dict,'a':1}))
else:
response_dict.update({'yes':0})
logging.debug("labs_home2 ==================")
return render_to_response('registration/login.html', context_instance=RequestContext(request, {'response_dict':response_dict,'a':1})
Also have a look at my question django get_profile error
authenticateonly verifies that username and password are correct and returns User instance found for that pair. To actually log user in and have it available in templates, sessions etc you need to call login