Sunday, July 31, 2011

Re: Customizing Form Field HTML Attributes

Take a look at the widgets used to display a form. From the

"On a real Web page, you probably don't want every widget to look the
same. You might want a larger input element for the comment, and you
might want the 'name' widget to have some special CSS class. To do this,
you use the Widget.attrs argument when creating the widget:

For example:

class CommentForm(forms.Form):
name = forms.CharField(
url = forms.URLField()
comment = forms.CharField(


Stuart MacKay
Lisbon, Portugal

> I would like to use the 'title' attribute of several form fields to hold our
> help_text, rather than displaying the text alongside the field. I don't see
> any way, though, to add or modify tag attributes on a form field. How would
> I do this?

You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

No comments:

Post a Comment