電子メールを持たない第2のユーザーを作成しようとすると、duplicate key value violates unique constraint "users_user_email_key" DETAIL: Key (email)=(None) already exists.
エラーが発生します。Django UniqueフィールドがNoneの値を返します。
メールフィールド定義:
def clean_email(self):
email = self.cleaned_data.get('email')
if email:
if email == "":
return None
else:
return email
else:
return None
は、私がここで間違って何をやっている:ユーザーの作成フォームから
email = models.EmailField(verbose_name='email address', max_length=255, unique=True, null = True, blank = True)
?すべての入力がありがとう、ありがとう!
remove unique = Trueと 'clean_mail'で重複をチェックしてください – Meska