Opened 10 years ago

Closed 10 years ago

#22685 closed Bug (needsinfo)

SimpleTemplateResponse not suitable as TemplateView.response_class

Reported by: Markus Bertheau Owned by: nobody
Component: Generic views Version: 1.6
Severity: Normal Keywords:
Cc: mbertheau@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

SimpleTemplateResponse not suitable as TemplateView.response_class because TemplateView calls the constructor with a kwarg request that SimpleTemplateResponse doesn't know.

I'm not sure if that's an intended use case for SimpleTemplateResponse though.

There's a related older commit https://github.com/django/django/commit/6fe3a444dfc47c81036fb9c382f7c6647a9faca5 but it's not in 1.6.

Change History (3)

comment:1 by Tim Graham, 10 years ago

No, it doesn't seem like it would be compatible. Is there something in the documentation that suggests it is?

comment:2 by Markus Bertheau, 10 years ago

I don't know of any such hint in the documentation.

I stumbled upon it while reading the Django code looking for how to make TemplateView not use a RequestContext so that I could set things like user and messages in the context.

comment:3 by Tim Graham, 10 years ago

Resolution: needsinfo
Status: newclosed

I guess you should override render_to_response to initialize the response_class without the request. I'm not sure we should make a change in Django to support this. Feel free to reopen the ticket if you have a proposed patch and we could evaluate it.

Note: See TracTickets for help on using tickets.
Back to Top