我一直在尝试几种方法,但似乎无法使其发挥作用。
以下是我的代码:
sparse_softmax_cross_entropy_with_logits
有谁知道为什么required = True不能使它成为必填字段?
答案 0 :(得分:0)
@WillemVanOnsem
在对您的问题的评论中说了什么,我将在此处进行扩展以使其更清晰:您应该调用super().clean_email()
以确保该字段的所有默认验证都已运行。
def clean_email(self):
email = super().clean_email()
if email is not None:
# check if account with email exists
if User.objects.filter(email=email).exists():
raise ValidationError('Email address already exists.')
return email