Обновили шапку и вывод всехтоваров. Добавили фильтры
This commit is contained in:
23
myproject/customers/forms.py
Normal file
23
myproject/customers/forms.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from django import forms
|
||||
from .models import Customer
|
||||
|
||||
class CustomerForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Customer
|
||||
fields = ['name', 'email', 'phone', 'loyalty_tier', 'notes']
|
||||
widgets = {
|
||||
'notes': forms.Textarea(attrs={'rows': 3}),
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
for field_name, field in self.fields.items():
|
||||
if field_name == 'notes':
|
||||
# Textarea already has rows=3 from widget, just add class
|
||||
field.widget.attrs.update({'class': 'form-control'})
|
||||
elif field_name == 'loyalty_tier':
|
||||
# Select fields need form-select class
|
||||
field.widget.attrs.update({'class': 'form-select'})
|
||||
else:
|
||||
# Regular input fields get form-control class
|
||||
field.widget.attrs.update({'class': 'form-control'})
|
||||
Reference in New Issue
Block a user