Closed ytyng closed 2 years ago
https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/core/admin.py#L412
in SitePermissionUserAdminForm, If there are multiple records for users with the same email, Raises MultipleObjectsReturned, and no catched.
MultipleObjectsReturned
Raises ValidationError(_("This email is already registered"))
ValidationError(_("This email is already registered"))
- Operating System: MacOS, Ubuntu - Python version: 3.8 - Django version: 3.2 - Database engine and version: MySQL 5.7 - Mezzanine version: 5.0.0 (85564606d4594f027b9ad7ff38c576a9bdd3096d)
I think
try: User.objects.exclude(id=form.instance.id).get(email=email) except User.DoesNotExist: return email raise ValidationError(_("This email is already registered"))
Change to
if User.objects.exclude(id=form.instance.id).filter(email=email).exists(): raise ValidationError(_("This email is already registered")) return email
:tada: This issue has been resolved in version 5.1.2 :tada:
The release is available on:
v5.1.2
Your semantic-release bot :package::rocket:
Is there an existing issue for this?
Current Behavior
https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/core/admin.py#L412
in SitePermissionUserAdminForm, If there are multiple records for users with the same email, Raises
MultipleObjectsReturned
, and no catched.Expected Behavior
Raises
ValidationError(_("This email is already registered"))
Steps To Reproduce
Environment
Anything else?
https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/core/admin.py#L412
I think
Change to