Opened 7 years ago

Last modified 7 years ago

#28943 closed Cleanup/optimization

Unenforce manual get_context_data() — at Version 1

Reported by: James Pic Owned by: nobody
Component: Generic views Version: 2.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by James Pic)

Currently, TemplateView inherits render_to_response(context) from TemplateResponseMixin which requires a context argument.

Instead, TemplateView should have its own render_to_response(context=None) that would get a context by default from get_context_data().

TemplateView.render_to_response() should call its ContextMixin.get_context_data() method automatically is because TemplateView inherits from both TemplateResponseMixin, and ContextMixin which provides the get_context_data() method.

Currently, the workaround is to call TemplateResponse.get(request, *args, kwargs), but users should really be calling what they mean to do instead: super().render_to_response()

Change History (1)

comment:1 by James Pic, 7 years ago

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