Is there any clever way to make django forms render field with asterisks after fields that are required? Or to provide some other clever for to mark required fields? I would
As of Django 1.2, if your form has an attribute named required_css_class, it will be added to BoundField.css_classes for required fields. You can then use CSS to style the required parts of the form as desired. A typical use case:
# views.py
class MyForm(django.forms.Form):
required_css_class = 'required'
…
…
/* CSS */
th.required { font-weight: bold; }
…
{{form.name.label_tag}}
{{form.name.errors}}{{form.name}}
If you use Form.as_table(), Form.as_ul, and Form.as_p, they do this automatically, adding the class to , , and , respectively.