mirror of
https://github.com/Lyxminxx/jast.git
synced 2026-10-11 12:51:51 +02:00
27 lines
902 B
Python
27 lines
902 B
Python
from django import forms
|
|
from django.contrib.auth.forms import UserCreationForm
|
|
from django.contrib.auth.models import User
|
|
from .models import Transaction
|
|
|
|
class TransactionForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Transaction
|
|
fields = ['title', 'amount', 'category', 'date']
|
|
|
|
|
|
class CustomUserCreationForm(UserCreationForm):
|
|
first_name = forms.CharField(max_length=30, required=True, label="First Name")
|
|
last_name = forms.CharField(max_length=30, required=True, label="Last Name")
|
|
|
|
class Meta(UserCreationForm.Meta):
|
|
model = User
|
|
fields = UserCreationForm.Meta.fields + ('first_name', 'last_name')
|
|
|
|
def save(self, commit=True):
|
|
user = super().save(commit=False)
|
|
user.first_name = self.cleaned_data['first_name']
|
|
user.last_name = self.cleaned_data['last_name']
|
|
if commit:
|
|
user.save()
|
|
return user
|