23 lines
925 B
Python
23 lines
925 B
Python
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'}) |