我正在自定义 django 用户模块并添加一些额外的字段
我的模型看起来像
class Drinker(models.Model):
user = models.OneToOneField(User)
birthday = models.DateField()
name = models.CharField(max_length = 100)
def __unicode__(self):
return self.name
这是我的注册视图
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))
现在我的问题是当用户在我的 auth_user 表中注册时,密码存储在计划文本中,即导致
Unknown password hashing algorithm '123'. Did you specify it in the PASSWORD_HASHERS setting?
登录时出错
但是对于超级用户的密码在 auth_user 表中是 SHA1 格式(我不确定)并且他们能够登录
请建议我如何在这里散列密码字段?