I am customizing the django user module and adding some extra fields
my model is looking like
class Drinker(models.Model):
user = models.OneToOneField(User)
birthday = models.DateField()
name = models.CharField(max_length = 100)
def __unicode__(self):
return self.name
And here is my register view
def DrinkerRegistration(request):
if request.user.is_authenticated():
return HttpResponseRedirect('/profile/')
if request.method == "POST":
form = RegistrationForm(request.POST)
if form.is_valid():
user = User.objects.create(username = form.cleaned_data['username'],email = form.cleaned_data['email'],password = form.cleaned_data['password'])
user.save()
drinker = Drinker(name = form.cleaned_data['name'],birthday = form.cleaned_data['birthday'],user=user)
drinker.save()
return HttpResponseRedirect('/profile/')
else:
form = RegistrationForm()
context = {'form':form}
return render_to_response('register.html',context,context_instance = RequestContext(request))
Now my question is when the user is registering in my auth_user table the password is storing in plan text i.e causing
Unknown password hashing algorithm '123'. Did you specify it in the PASSWORD_HASHERS setting?
error at the time of login
but for superusers passwords are in SHA1 format (i am not sure ) in auth_user table and they are able to login
please suggest me how to hash the password field here?
Do not use
User.objects.create(), useUser.objects.create_user()– it will hash provided password using correct algorithm.