Ticket #10190: http_response_charset.diff

File http_response_charset.diff, 1.2 KB (added by Wonlay, 15 years ago)
  • django/http/__init__.py

     
    269269    status_code = 200
    270270
    271271    def __init__(self, content='', mimetype=None, status=None,
    272             content_type=None):
     272            content_type=None, charset=None):
    273273        from django.conf import settings
    274         self._charset = settings.DEFAULT_CHARSET
    275         if mimetype:
    276             content_type = mimetype     # For backwards compatibility
     274        self._charset = charset
     275        if not self._charset:
     276            self._charset = settings.DEFAULT_CHARSET
    277277        if not content_type:
    278             content_type = "%s; charset=%s" % (settings.DEFAULT_CONTENT_TYPE,
    279                     settings.DEFAULT_CHARSET)
     278            if not mimetype:
     279                mimetype = settings.DEFAULT_CONTENT_TYPE # Maybe we should call it settings.DEFAULT_MIMETYPE?
     280            content_type = "%s; charset=%s" % (mimetype,
     281                    self._charset)
    280282        if not isinstance(content, basestring) and hasattr(content, '__iter__'):
    281283            self._container = content
    282284            self._is_string = False
Back to Top