I'm getting a duplicate key value violates unique constraint "users_user_email_key" DETAIL: Key (email)=(None) already exists.
error when trying to create a second user that doesn't have an email.
Email field definition:
email = models.EmailField(verbose_name='email address', max_length=255, unique=True, null = True, blank = True)
From the form creating the user:
def clean_email(self):
email = self.cleaned_data.get('email')
if email:
if email == "":
return None
else:
return email
else:
return None
What am I doing wrong here? All input is appreciated, thanks!