#19668: Form enhancement: `Form.set_data` to set data an files -----------------------------+-------------------- Reporter: bruth | Owner: nobody Type: New feature | Status: new Component: Forms | Version: master Severity: Normal | Keywords: Triage Stage: Unreviewed | Has patch: 1 Easy pickings: 0 | UI/UX: 0 -----------------------------+-------------------- This simply moves the logic for setting `is_bound`, `data` and `files` into a method which enables setting the data after form initialization. This is a backwards compatible. This makes it easier to not have to initialize a form twice in view. It changes from this idiom:
{{{#!python def view(request): if request.method == 'POST': form = Form(request.POST, request.FILES) ... else: form = Form() ... }}} to simply this: {{{#!python def view(request): form = Form() if request.method == 'POST': form.set_data(request.POST, request.FILES) ... }}} This reduces clutter and redundancy when there are a lot of form arguments passed. -- Ticket URL: <https://code.djangoproject.com/ticket/19668> 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 post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.