I want to add the authentication functionality in my application. I have below code snippet:
user = User.objects.create_user('jkd')
user.set_password('space')
user.save
user = authenticate(username='jkd', password='space')
print "User:",user
It always prints the "User:None". I have also added below in my settings.py file:
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend', # default
# any other authentication backends
)
I have gone through answers of same question in different thread but it doesn't help me.
There is typo in your code, thus the record has not been saved yet
Change from
user.save
to
user.save()