Skip to content

Commit

Permalink
Fixed username validation on registration form to match Django Admin …
Browse files Browse the repository at this point in the history
…criterion (UnicodeUsernameValidator).
  • Loading branch information
cknaut committed Dec 1, 2019
1 parent dcb1a0a commit b6c900f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions userhandling/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from bootstrap_datepicker_plus import DateTimePickerInput
from django.utils.translation import gettext_lazy as _
from django.db.utils import OperationalError
from django.contrib.auth.validators import UnicodeUsernameValidator

class DivErrorList(ErrorList):
def __str__(self):
Expand All @@ -23,11 +24,18 @@ def as_divs(self):
if not self: return ''
return ''.join(['<div class="errorlist">%s</div>' % e for e in self])



# Code taken from https://stackoverflow.com/questions/24935271/django-custom-user-email-account-verification
class RegistrationForm(forms.Form):
''' Testing Flag used for calling form in testing setup in order to avoid recaptcha'''
username = forms.CharField(label="", widget=forms.TextInput(
attrs={'placeholder': 'Username', 'class': 'form-control input-perso'}), max_length=100)
username = forms.CharField(
label="",
validators=[UnicodeUsernameValidator()],
widget=forms.TextInput(
attrs={'placeholder': 'Username', 'class': 'form-control input-perso'}),
max_length=150)

email = forms.EmailField(label="", widget=forms.EmailInput(attrs={
'placeholder': 'Email', 'class': 'form-control input-perso'}), max_length=100, error_messages={'invalid': ("Invalid Email.")})
first_name = forms.CharField(label="", widget=forms.TextInput(
Expand Down

0 comments on commit b6c900f

Please sign in to comment.