从Django用户中删除电子邮件 [英] Removing an email from a Django User
本文介绍了从Django用户中删除电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Django中,我尝试以下Django用户:
user.email =无
用户。 save()
我收到例外:
NOT NULL约束失败:auth_user.email
一个关于删除用户的电子邮件?
解决方案
在Django中,用户定义如下:
email = models.EmailField(_('email address'),blank = True)
$ p因此,用户的电子邮件可以是空白的(即
)而不是空(即
无
)。您使用以下内容清除用户的电子邮件:user.email =
user.save()
When in Django I try the following with a Django user:
user.email = None user.save()
I get the exception:
NOT NULL constraint failed: auth_user.email
How does one go about deleting a user's email?
解决方案In Django, a User is defined as follows:
email = models.EmailField(_('email address'), blank=True)
Consequently, a user's email can be blank (i.e.
""
) but not null (i.e.None
). You clear a user's email with the following:user.email = "" user.save()
这篇关于从Django用户中删除电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文