Open fargerio opened 4 years ago
i think duration is better
I'm trying to customize the form fields, but the ModelForm seems to ignore all my efforts:
class AppointmentForm(forms.ModelForm):
# i'm trying to customize form fields, but nothing is working:
# first way
description = forms.CharField(widget=forms.Textarea(
attrs={'class': 'test1', 'maxlength': 123, 'rows': 40})),
# second way
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['description'].widget = forms.Textarea(
attrs={'class': 'test2', 'maxlength': 155, 'rows': 4})
class Meta:
model = Appointment
fields = ['name', 'description',
'start_time', 'end_time', 'staffmember', 'room_name']
# third way
widgets = {
'description': forms.Textarea(attrs={
'class': 'test3', 'cols': 20, 'rows': 20}),
}
any ideas?
The problem was that I was also setting fields = […]
on the CreateView, and those override any configuration I do in AppointmentForm.
maybe duration instead of end time?