Opened 7 years ago

Closed 7 years ago

#27517 closed Bug (fixed)

TemplateResponseMixin with charset does not work

Reported by: Kosei Kitahara Owned by: nobody
Component: Generic views Version: 1.10
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Kosei Kitahara)

When create a class based view which contain TemplateResponseMixin,

class MyTemplateView(TemplateResponseMixin, ContextMixin, View):
    def get(self, request, *args, **kwargs):
        context = self.get_context_data(**kwargs)
        return self.render_to_response(context, charset=kwargs.get('charset', 'utf-8'))

TemplateResponseMixin.render_to_response calls SimpleTemplateResponse. __init__ with a charset keyword argument.
But, the above method passed charset as a non-keyword argument.
In addition, content_type, status are passed also as nonーkeyword arguments, which seems in a wrong order.

Change History (5)

comment:1 by Kosei Kitahara, 7 years ago

Description: modified (diff)

comment:2 by Kosei Kitahara, 7 years ago

Description: modified (diff)

comment:3 by Adam Johnson, 7 years ago

Summary: TemplateResponseMixin with charset does not workedTemplateResponseMixin with charset does not work

comment:4 by Tim Graham, 7 years ago

Has patch: set
Triage Stage: UnreviewedAccepted

comment:5 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: newclosed

In f095b249:

Fixed #27517 -- Fixed charset param in SimpleTemplateResponse.init().

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