This repository has been archived on 2025-03-03. You can view files and clone it, but cannot push or open issues or pull requests.
facturio/accounts/forms.py

30 lines
1,001 B
Python

from crispy_forms import helper, layout
from django.contrib.auth.forms import AuthenticationForm, UserCreationForm
from django.utils.translation import gettext_lazy as _
from .models import User
# from .models import User
class LoginForm(AuthenticationForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper = helper.FormHelper()
self.helper.form_action = "accounts:login"
self.helper.form_method = "post"
self.helper.add_input(layout.Submit('submit', _('Login')))
class RegisterForm(UserCreationForm):
class Meta:
model = User
fields = UserCreationForm.Meta.fields + ("first_name", "last_name", "email")
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper = helper.FormHelper()
self.helper.form_action = "accounts:register"
self.helper.form_method = "post"
self.helper.add_input(layout.Submit('submit', _('Register')))