[Django]-Frustrated by Django User matching query does not exist message



In your code

def clean_email2(self):
        # here
        if User.objects.get(email = email1):
          raise forms.ValidationError("The email address '%s' is already associated with an account. This typically means you created an account in the past. Please use it." % email1)

The get() could cause DoesNotExist but is not captured. Is that the issue?

Also, please provide full traceback of the line making the issue.

Furthermore, according to the doc, its better to put the logic of validating passwords & emails to the clean() method.


Leave a comment