Ticket #7453: 7453.backwards.diff

File 7453.backwards.diff, 2.3 KB (added by telenieko, 7 years ago)

Non silent backwards compatible version.

  • django/http/__init__.py

    diff --git a/django/http/__init__.py b/django/http/__init__.py
    index 7faa3c8..1dcd395 100644
    a b class HttpResponse(object): 
    259259
    260260    status_code = 200
    261261
    262     def __init__(self, content='', mimetype=None, status=None,
    263             content_type=None):
     262    def __init__(self, content='', mimetype=None, status_code=None,
     263            content_type=None, status=None):
    264264        from django.conf import settings
    265265        self._charset = settings.DEFAULT_CHARSET
    266266        if mimetype:
    class HttpResponse(object): 
    275275            self._container = [content]
    276276            self._is_string = True
    277277        self.cookies = SimpleCookie()
    278         if status:
    279             self.status_code = status
     278        if status_code and status:
     279            raise ValueError, "You cannot set both status_code and status, note that status is deprecated."
     280        elif status:
     281            from warnings import warn
     282            warn("The status parameter is deprecated, please use status_code instead.",
     283                DeprecationWarning)
     284            status_code = status
     285        elif status_code:
     286            self.status_code = status_code
    280287
    281288        # _headers is a mapping of the lower-case name to the original case of
    282289        # the header (required for working with legacy systems) and the header
  • docs/request_response.txt

    diff --git a/docs/request_response.txt b/docs/request_response.txt
    index 866a697..64e96de 100644
    a b it's easy to forget the syntax, so we've included it here. 
    426426Methods
    427427-------
    428428
    429 ``__init__(content='', mimetype=None, status=200, content_type=DEFAULT_CONTENT_TYPE)``
     429``__init__(content='', mimetype=None, status_code=200, content_type=DEFAULT_CONTENT_TYPE)``
    430430    Instantiates an ``HttpResponse`` object with the given page content (a
    431431    string) and MIME type. The ``DEFAULT_CONTENT_TYPE`` is ``'text/html'``.
    432432
    Methods 
    434434    return strings, and those strings will be joined together to form the
    435435    content of the response.
    436436
    437     ``status`` is the `HTTP Status code`_ for the response.
     437    ``status_code`` is the `HTTP Status code`_ for the response.
    438438
    439439    **(New in Django development version)** ``content_type`` is an alias for
    440440    ``mimetype``. Historically, the parameter was only called ``mimetype``,
Back to Top