From django/forms/forms.py:
def label_tag(self, contents=None, attrs=None):
..
def as_widget(self, widget=None, attrs=None, only_initial=False):
..
From my templates I call the label_tag as follows:
{{ form.my_field.label_tag }}
which outputs the label.
How should I provide the arguments to those tag as in their definition? For example I want to provide an alternative label text and css classes.
I tried something like:
{{ form.my_field.label_tag contents='My alternative label' }}
but it gives me:
Could not parse the remainder: ' contents='My alternative label'' from 'form.code.label_tag contents='My alternative label''
The same goes for the attrs field. Can I supply a value for that one from the template. I would like to provide the css class. For css class I'm using a filter at the moment but while going through the Django source code I noticed label_tag and as_widget has these additional arguments, and that's why I'm wondering now I can supply them from my templates.
(I'm using Django 1.4 on App Engine)