33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
|
|
from django import forms
|
|
from django.contrib.auth.models import User
|
|
|
|
from users.validators import usernameValidator
|
|
|
|
class UserRegisterForm(UserCreationForm):
|
|
field_order = ("username", "password1", "password2")
|
|
|
|
username = forms.CharField(min_length=3,
|
|
max_length=16,
|
|
label="Username",
|
|
required=True,
|
|
validators=[usernameValidator],
|
|
help_text="3-16 chars, alphanumeric and _- pls")
|
|
|
|
class Meta:
|
|
model = User
|
|
fields = [
|
|
"username",
|
|
"password1",
|
|
"password2",
|
|
]
|
|
|
|
class UserLoginForm(AuthenticationForm):
|
|
def __init__(self, *args, **kwargs):
|
|
super(UserLoginForm, self).__init__(*args, **kwargs)
|
|
|
|
username = forms.CharField(min_length=3,
|
|
max_length=16,
|
|
label="Username",
|
|
required=True,
|
|
validators=[usernameValidator]) |