This repository has been archived on 2025-09-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Employee-Management-Portal/accounts/forms.py
Alicja Cięciwa c26db18f86 registration page
2020-11-11 18:43:45 +01:00

50 lines
1.3 KiB
Python

from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
class RegisterForm(UserCreationForm):
class Meta:
model = User
fields = ['username', 'password1', 'password2']
def __init__(self, *args, **kwargs):
super(RegisterForm, self).__init__(*args, **kwargs)
self.fields['username'] = forms.CharField(
widget=forms.TextInput(attrs={
'placeholder': 'Nazwa użytkownika'
}),
error_messages={
'required': 'Wpisz nazwę użytkownika',
})
self.fields['password1'] = forms.CharField(
widget=forms.PasswordInput(attrs={
'placeholder': 'Hasło'
}),
error_messages={
'required': 'Podaj hasło',
})
self.fields['password2'] = forms.CharField(
widget=forms.PasswordInput(attrs={
'placeholder': 'Powtórz hasło'
}),
error_messages={
'required': 'Podaj hasło',
})
for field in ['username', 'password1', 'password2']:
self.fields[field].help_text = None
self.fields[field].label = ''