在注册时保存我的用户后,我收到以下错误消息。有人可以解释为什么吗?
谢谢
错误信息
IntegrityError at /member/registration/
(1048, "Column 'user_id' cannot be null")
Exception Type: IntegrityError at /member/registration/
Exception Value: (1048, "Column 'user_id' cannot be null")
视图.py
if form.is_valid():
# If form has passed all validation checks then continue to save member.
user = User.objects.create_user(
username=form.cleaned_data['username'],
email=form.cleaned_data['email'],
password=form.cleaned_data['password']
)
user.save()
#member = User.get_profile()
#member.name = form.cleaned_data['name']
#member.save()
member = Member(
name=form.cleaned_data['name']
)
member.save()
模型.py
class Member (models.Model):
user = models.OneToOneField(User)
name = models.CharField(max_length=100)
def __unicode__(self):
return self.name