Wednesday, February 24, 2010

Get id attribute in a form

Hello,

i have a simple question, how can i get the id attribute (which
correspond to html id) from a form's field ?

example :
class MyModel(...):
test = CharField(...)

class MyForm(ModelForm):
class Meta:
model = MyModel

I search for something like :
f=MyForm()
f.fields['test'].id => which will correspond to the html id

When i use my form i know there is an auto_id attribute for each field
which gives me the html correspondent id but if i set the auto_id to
False (f = MyForm(auto_id=False)) on what can i rely ?

I need that to have the id attribute in a custom widget.

Can anyone help me ?


Thanks


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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate