Opened 14 years ago
Last modified 12 years ago
#17795 closed Cleanup/optimization
kwargs not passed on by django.views.generic.edit import ProcessFormView — at Initial Version
| Reported by: | 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
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))
++      kwargsform = form
++      return self.render_to_response(self.get_context_data(kwargs))