73115

Question:
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?
Answer1: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()