When you create your form, you can specify extra attributes to each
widget of each field. For example:

myfield = forms.CharField(widget=forms.Textarea(attrs={'cols':80,
'rows':80})

So as one of the keys in your attrs argument, you can make it 'class'
and then provide the class name as the value.

On Dec 11, 5:46 pm, codecowboy <[email protected]> wrote:
> Thank you in advance for any feedback.
>
> Here is what I have {{ form.name }}. I would like to set the class
> attribute for this form element to "style01".  Is this possible?
>
> If it is not possible then I have been trying to get this working as
> well without much luck.
> <input id="id_name" class="style01" type="text" name="name"
> maxlength="50" value="{{ form.name.value }}" />
> I realize that this syntax is incorrect but I'm trying to illustrate
> what I am trying to do.  Is there anyway to access the value of a form
> field from the template?  If the user submits data that does not
> validate, I do not want them to have to fill out the form twice.
>
> I found one discussion suggesting that I make the form's cleaned data
> available to the view but that feels hackish although I'm not above
> it!  I was just hoping that there was a cleaner way to do this.
>
> Thank you.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to