We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chapter 6 adds validation to ensure that email addresses are not reused when a user is registering or editing their profile.
However, the User object at
User
Django-5-By-Example/Chapter06/bookmarks/account/forms.py
Line 34 in a4c1e4e
Line 46 in a4c1e4e
Comparing to https://github.com/PacktPublishing/Django-4-by-example/blob/main/Chapter05/bookmarks/account/forms.py, it looks like the import of User was replaced with get_user_model without fixing these two instances.
get_user_model
Doing something like the following solves the issue:
def clean_email(self): data = self.cleaned_data["email"] user = get_user_model() if user.objects.filter(email=data).exists(): raise forms.ValidationError("Email already in use.") return data ... def clean_email(self): data = self.cleaned_data["email"] user = get_user_model() qs = user.objects.exclude(id=self.instance.id).filter(email=data) if qs.exists(): raise forms.ValidationError("Email already in use.") return data
The text was updated successfully, but these errors were encountered:
the same issue is in chapter 5
Sorry, something went wrong.
No branches or pull requests
Chapter 6 adds validation to ensure that email addresses are not reused when a user is registering or editing their profile.
However, the
User
object atDjango-5-By-Example/Chapter06/bookmarks/account/forms.py
Line 34 in a4c1e4e
Django-5-By-Example/Chapter06/bookmarks/account/forms.py
Line 46 in a4c1e4e
Comparing to https://github.com/PacktPublishing/Django-4-by-example/blob/main/Chapter05/bookmarks/account/forms.py, it looks like the import of
User
was replaced withget_user_model
without fixing these two instances.Doing something like the following solves the issue:
The text was updated successfully, but these errors were encountered: