Ticket #3526: content_type.diff

File content_type.diff, 1.3 KB (added by Simon Willison, 16 years ago)

Patch to add content_type argument without breaking mimetype

  • django/http/__init__.py

     
    155155
    156156class HttpResponse(object):
    157157    "A basic HTTP response, with content and dictionary-accessed headers"
    158     def __init__(self, content='', mimetype=None):
     158    def __init__(self, content='', content_type=None, mimetype=None):
    159159        from django.conf import settings
    160160        self._charset = settings.DEFAULT_CHARSET
    161         if not mimetype:
    162             mimetype = "%s; charset=%s" % (settings.DEFAULT_CONTENT_TYPE, settings.DEFAULT_CHARSET)
     161        if mimetype:
     162            content_type = mimetype # For backwards compatibility
     163        if not content_type:
     164            content_type = "%s; charset=%s" % (settings.DEFAULT_CONTENT_TYPE, settings.DEFAULT_CHARSET)
    163165        if not isinstance(content, basestring) and hasattr(content, '__iter__'):
    164166            self._container = content
    165167            self._is_string = False
    166168        else:
    167169            self._container = [content]
    168170            self._is_string = True
    169         self.headers = {'Content-Type': mimetype}
     171        self.headers = {'Content-Type': content_type}
    170172        self.cookies = SimpleCookie()
    171173        self.status_code = 200
    172174
Back to Top