Ticket #2946: django-http-mimetype.diff

File django-http-mimetype.diff, 743 bytes (added by dummy@…, 18 years ago)

make charset set for mimetypes starting with 'text/'

  • django/http/__init__.py

     
    159159        from django.conf import settings
    160160        self._charset = settings.DEFAULT_CHARSET
    161161        if not mimetype:
    162             mimetype = "%s; charset=%s" % (settings.DEFAULT_CONTENT_TYPE, settings.DEFAULT_CHARSET)
     162            mimetype = settings.DEFAULT_CONTENT_TYPE
     163        if mimetype.startswith('text/') and not 'charset=' in mimetype:
     164            mimetype = "%s; charset=%s" % (mimetype, settings.DEFAULT_CHARSET)
    163165        if hasattr(content, '__iter__'):
    164166            self._container = content
    165167            self._is_string = False
Back to Top