Django - Field attributes in widget context

Viewed 35

As I am using some more exotic css framework I would like to change the behaviour of the text input (provide it with label etc. by default).

  • I have overridden the template in django/forms/widgets/input.html

Unfortunately the widget context is missing the field, so I cannot use field properties like help_text, label, etc in my template. Therefore I would need to override the TextInput widget.

My two options are now:

  • Setting my own widget class for every single field in my Form / Modelform classes

  • Using My custom ModelForm which iterates all the fields in __init__ and replaces the widget.

  • Is there any better way to override django's default text_input widget?

  • Does is there any other way to get field.errors and field.label into the widget (Or is there a reason why there is no label in the widget context)?

0 Answers
Related