display name uniqueness

This commit is contained in:
Matteo Rosati
2026-02-11 12:26:54 +01:00
parent 6cbaf5f6ee
commit 01fd047568
4 changed files with 24 additions and 1 deletions

View File

@@ -53,6 +53,14 @@ def register(request: HttpRequest) -> HttpResponse:
if email and User.objects.filter(username=email).exists():
errors.append("An account with that email already exists.")
if (
display_name
and UserProfile.objects.filter( # type: ignore[attr-defined]
display_name=display_name
).exists()
):
errors.append("That display name is already taken.")
if errors:
for error in errors:
messages.error(request, error)