#24598: JsonResponse loses encoding support in Content-Type header
-------------------------------+--------------------------------------
     Reporter:  funkybob       |                    Owner:  nobody
         Type:  Bug            |                   Status:  new
    Component:  HTTP handling  |                  Version:  1.8
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Unreviewed
    Has patch:  1              |      Needs documentation:  1
  Needs tests:  1              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+--------------------------------------

Comment (by funkybob):

 Oops, forgot the second part of the patch:

 {{{
 @@ -470,11 +470,11 @@ class JsonResponse(HttpResponse):
      :param safe: Controls if only ``dict`` objects may be serialized.
 Defaults
        to ``True``.
      """
 +    default_content_type = 'application/json'

      def __init__(self, data, encoder=DjangoJSONEncoder, safe=True,
 **kwargs):
          if safe and not isinstance(data, dict):
              raise TypeError('In order to allow non-dict objects to be '
                  'serialized set the safe parameter to False')
 -        kwargs.setdefault('content_type', 'application/json')
          data = json.dumps(data, cls=encoder)
          super(JsonResponse, self).__init__(content=data, **kwargs)
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24598#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.94203c9424a6a6755c1d03104b5a202a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to