On Sun, Mar 2, 2014 at 10:29 PM, Sai Prasanna <sai.r.prasa...@gmail.com>wrote:
> I saw that the render method in django.form.widgets. multiwidget class > changes the id of internal widgets .Shouldn't it set internal widget ids if > they are specified in attrs of widgets passed to the init. > Hi Sai, If I'm understanding you correctly, maybe :-) I can certainly understand your position that if you're manually specifying an ID for a widget, then Django should use it in preference to generating it's own. From a quick inspection, normal "single" widgets certainly take this approach. The behaviour you're seeing in MultiWidget looks like it's an artefact of making it easy to identify the individual subwidgets. If you pass in an id at the Field level, or as an ID attribute of the *multiwidget*, it will be preserved, and the sub widgets will get _0, _1... prefixes as appropriate. I can see your point that if you're manually specifying the widget IDs for the subwidgets, they should be preserved. If you worked up a full patch for this (with tests, and probably some clarifying documentation), I imagine it would probably be committed. My bigger question to you would be why you are specifying IDs at the widget level in the first place. To me, this is a flag that you're possibly being a little *too* specific in your code. If you're hard-coding (and requiring) a specific ID, it means your code is really only going to be useful in one particular place and time. You may well have a good reason for needing a specific ID for subwidgets, and if you do, that's fine. However, if you're just fixing IDs because you think you have to, I'd suggest taking a closer look at ways of making your code more reusable (e.g., by using class specifiers instead of IDs). Yours, Russ Magee %-) -- 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-qZN_M-GswG8qCtVwXMQnMJ3Dc7%2Bi2%3DBGoDFqniHuMpw%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.