Thanks a lot for the great answers, and the information about the form prefix (it is what I was looking for)!
Sorry, I missed the replies 1 week ago :( Thanks again, Romain On Mar 6, 1:42 am, Eric Abrahamsen <gir...@gmail.com> wrote: > On Mar 5, 2009, at 11:14 AM, Alex Gaynor wrote: > > > > > > > On 3/4/09, Eric Abrahamsen <gir...@gmail.com> wrote: > > >> 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 theHTMLid > >>> 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-... > > >> 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 > > > Auto_I'd won't help. The issue is the names conflict in the POST so > > this is an issue for prefix. > > Whoops, thanks for pointing that out! > > E > > > > > Alex > > > -- > > "I disapprove of what you say, but I will defend to the death your > > right to say it." --Voltaire > > "The people's good is the highest law."--Cicero --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---