newforms: clean way to customize a widget's label?

0 views
Skip to first unread message

arthur debert

unread,
Jul 9, 2007, 11:00:31 AM7/9/07
to Django users
Hi Folks.

I've looked through the docs (which are pretty godd by the way) and
the source code, but it look as it's not easy to customize the
<label> tag that goes along with a widget.

When instantiating a widget I can pass the attrs dict and those
properties will be rendered as html attributes. But the label
parameter takes only a string, and I would love to specify what (css)
classes get rendered through that label, something like:

my_field.widget= (label : {"name": "Your name", "class": "quiet
small"}, widget=...)

so that {{field.label}} would render:
<label class="quiet smal" id="... >

Is there a way to do this, short or writing my own widget with a
custom "render" method?

Thanks,
Arthur

leifbyron

unread,
Jul 9, 2007, 9:06:08 PM7/9/07
to Django users

arthur debert

unread,
Jul 12, 2007, 11:17:48 PM7/12/07
to Django users
Hi Leif.

Thanks for the pointer.
This certainly looks userful, but if I understand this right it makes
easier to link to external js and css, not customize the output of the
<label> tag.

Cheers
Arthur

On Jul 9, 10:06 pm, leifbyron <leifstrickl...@gmail.com> wrote:
> Arthur,
>
> You'll probably find this of interest:
>

> http://groups.google.com/group/django-developers/browse_thread/thread...
>
> Cheers,
> Leif

Reply all
Reply to author
Forward
0 new messages