问题
I am using djnago all-auth to create custom user accounts. When creating an account with email and password, if account with a email already exits it gives an error (UNIQUE constraint failed: account_emailaddress.email) but I would like to display message that an account with this email already exists instead of throwing an error. What is the best way to handle this? In general I would use AJAX to verify and display message for my own views but I do not know how to deal here with django all-auth package.
回答1:
I'll suggest that you should override the signup/login form in order to manage this error. Have you checked the documentation? https://django-allauth.readthedocs.io/en/latest/forms.html
I think this answer is related to your question.
A relatively similar approach is given in this answer:
- Create your custom view that inherits
SignupView
and overrides the form class - Create a custom form that inherits from
SignupForm
and overrides the email validation message - In your own urls.py add the following after
include('allauth.urls')
to override theaccount_signup
url
来源:https://stackoverflow.com/questions/61327185/django-all-auth-create-account-with-email-unique-constraint-failed-display-m