1

I'm am trying to test the form fields have or don't have the required attribute, but I don't know where to find it. This is what I have tried:

form.fields[field].widget.attrs['required']

But I get this error:

form.fields[field].widget.attrs['required']
KeyError: 'required'
Carl Brubaker
  • 1,602
  • 11
  • 26

1 Answers1

2

The instance of field has required attribute:

form.fields[field].required
Ivan
  • 2,469
  • 1
  • 12
  • 24