Required class attribute in django ModelForm
Days ago' I was developing a front-end form in order to give users the opportunity to subscribe to a newsletter. I used the django ModelForm class because I didn't need nothing special except from hiding some model fields.
But I run into a problem, the compulsory fileds where handled properly in the sense that the form submission returned an error if such fields weren't filled, but there wasn't any attribute assigned to the label element in order to style it different from non-compulsory fields.
Nothing special here, nor complicated, but it costs me a while to find the reason for this, so I'll share it with you. The simple solution is to add a line (