#22719: Proposal: Delayed Form binding (with working example code) ------------------------------------+-------------------------------------- Reporter: bernhard.hermann@… | Owner: nobody Type: New feature | Status: new Component: Forms | Version: 1.6 Severity: Normal | Resolution: Keywords: bound unbound bind | Triage Stage: Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 ------------------------------------+-------------------------------------- Changes (by bernhard.hermann@…):
* status: closed => new * resolution: wontfix => Comment: I've pondered over this for a bit longer now. Conclusion: The duplication still bothers me a lot. Your example {{{ form_kwargs = {'prefix': 'something-%s' % (some_id,), 'label_suffix': ': '} form = MyForm(request.POST, **form_kwargs) form = MyForm(**form_kwargs) }}} would, IMO, be better written as {{{ form = MyForm({'prefix': 'something-%s' % (some_id,), 'label_suffix': ': '}) form.bind(request.POST) }}} because this reduces code length, eliminates redundancy/repetition, is more concise and, to me at least, is clearer. In many cases it would be a wasted effort to introduce & duplicate the variable name 'form_kwargs' three times just to use the same arguments for the same form. (note: the 'form' object in the first line of my example is equivalent to the 'form' object in the third line of your example.) I am much in favor of the syntax I proposed. I still think "binding" of Form objects should happen after instantiation. It's the only thing that differentiates a 'bound' form from an 'unbound' form and shouldn't introduce the necessity of copying all that code. I would be happy to read your opinion(s) on this :-) -- Ticket URL: <https://code.djangoproject.com/ticket/22719#comment:4> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/087.ae2fd8ae87681c1e8b13315cfb6d6b17%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.