On Mar 5, 2009, at 8:05 AM, Romain wrote:

>
> Hello,
>
> On the same page I have 2 ModelForm that happen to have an attribute
> with the same name. Is it possible to choose the name of the HTML id
> generated by the form without having to change the real name of the
> model attribute?

A simple solution would be to instantiate your ModelForms with a prefix:
http://docs.djangoproject.com/en/dev/ref/forms/api/#prefixes-for-forms

Another, finer-grained choice is using the auto_id argument:
http://docs.djangoproject.com/en/dev/ref/forms/api/#configuring-html-label-tags

Hope that's what you're looking for,

Eric

>
> e.g.
> class A(models.Model):
>  amount = models.IntegerField()
>
> class B(models.Model):
>  amount = models.IntegerField()
>
>
> class AForm(ModelForm):
>  class Meta:
>    model = A
>
> class BForm(ModelForm):
>  class Meta:
>    model = B
>
> Conflict of ids when forms printed:
> ...
> <input type="text" name="amount" id="id_amount" />
> ...
> <input type="text" name="amount" id="id_amount" />
> ...
>
> Thanks a lot,
>
> Romain
>
> >


--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to