Hi Rafer,

I think what you're looking for is the "attrs" argument on a form widget.

https://docs.djangoproject.com/en/1.8/ref/forms/widgets/#django.forms.Widget.attrs

That page has some examples showing adding a class to a field as a specific
example:

class CommentForm(forms.Form):
    name = forms.CharField(widget=forms.TextInput(attrs={'class':
'special'}))
    url = forms.URLField()
    comment = forms.CharField(widget=forms.TextInput(attrs={'size': '40'}))

Yours,
Russ Magee %-)


On Wed, Jul 22, 2015 at 12:05 AM, Rafer Johnson <rafer...@gmail.com> wrote:

> Hi Guys,
>
> I would like to know how I can apply unique identifiers to individual form
> elements. Currently I am trying to apply unique classes to individual
> inputs in a form and finding it impossible based on what I know about
> Django form helpers. I was trying to apply a unique background to each of
> two radio buttons and I had to use JQuery combined with the "for"
> information in the radio button to apply the style since I cannot add a
> class to each element.
>
> Would love to hear if there is another solution to this.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/557b9695-0da7-469c-beea-659a2dd811a3%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/557b9695-0da7-469c-beea-659a2dd811a3%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJxq84-R21sFvdCTBpCFHT%2BZJU73FVJ4n9sYFi6OV2mheMAszw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to