Opened 13 years ago

Last modified 11 years ago

#17795 closed Cleanup/optimization

kwargs not passed on by django.views.generic.edit import ProcessFormView — at Version 3

Reported by: ed.crewe@… Owned by: nobody
Component: Generic views Version: dev
Severity: Normal Keywords:
Cc: lemaire.adrien@…, bmispelon@…, polmuz Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by Jannis Leidel)

Although these do get attached to self.kwargs for use within the class, this causes problems for decorators of the get_context_data method.

kwargs which you may expect to be available for use by decorators you create are unset by this mixin.

NB: In my case this was related to testing user object permissions - hence the need to have the context data

Patching as below fixes it:

    A mixin that processes a form on POST.                                                                                                                                                
    """
    def get(self, request, *args, **kwargs):
        form_class = self.get_form_class()
        form = self.get_form(form_class)
--      return self.render_to_response(self.get_context_data(form=form))
++      kwargs['form'] = form
++      return self.render_to_response(self.get_context_data(**kwargs))

Change History (3)

comment:1 by anonymous, 13 years ago

Same issue in

dates.BaseDateListView.get
list.BaseListView.get
detail.BaseDetailView.get

comment:2 by Jannis Leidel, 13 years ago

Description: modified (diff)

Updated ticket description.

comment:3 by Jannis Leidel, 13 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top