I'm trying to find out which field is a DateField
and thereby assign a class='date'
. How do I get the field type?
The following code does not work but displays the logic:
class MeuForm(forms.ModelForm):
...
def __init__(self, *args, **kwargs):
super(MeuForm, self).__init__(*args, **kwargs)
for field_name, field in self.fields.items():
if field == "DateField": # (exemplo) como saber que é um DateField?
field.widget.attrs['class'] = 'date'