Register admin user

This commit is contained in:
Mouse Reeve
2022-02-17 11:25:11 -08:00
parent ed536e6b41
commit 23d0d3e2b7
4 changed files with 63 additions and 21 deletions

View File

@ -54,6 +54,15 @@ class RegisterForm(CustomForm):
help_texts = {f: None for f in fields}
widgets = {"password": PasswordInput()}
def clean(self):
"""Check if the username is taken"""
cleaned_data = super().clean()
localname = cleaned_data.get("localname").strip()
if models.User.objects.filter(localname=localname).first():
self.add_error(
"localname", _("User with this username already exists")
)
class RatingForm(CustomForm):
class Meta: