diff options
| author | Anler Hp | 2014-08-01 10:20:10 +0200 | 
|---|---|---|
| committer | Anler Hp | 2014-08-01 10:20:10 +0200 | 
| commit | ebcc78d96cf6f4cd6e464cd6b8eccd83305900c2 (patch) | |
| tree | bcc9c10997659c55d67d81ec897d32936a2e8a11 /rest_framework/response.py | |
| parent | 18f2ca4b020f7a06eecd45a83473b0beb413f98e (diff) | |
| download | django-rest-framework-ebcc78d96cf6f4cd6e464cd6b8eccd83305900c2.tar.bz2 | |
Leave status responsibility to parent class
Django's `HttpResponse` class checks for the `status` param when it's
initialized, if it's `None` it uses the class attribute
`status_code` and thanks to that we can do things like:
```
class BadRequest(HttpResponse):
    status_code = 400
```
Now, that doesn't work when inheriting from rest-framework's `Response`:
```
class BadRequest(rest_framework.response.Response):
    status_code = 400  # Bad, it's always ignored
```
Because a default status of `200` is being specified in
`rest_framework.response.Response`. I think is more Django-friendly to
just leave that status default value to `None` and leave the
responsibility of choosing its value to the parent class: `HttpResponse`.
Diffstat (limited to 'rest_framework/response.py')
| -rw-r--r-- | rest_framework/response.py | 2 | 
1 files changed, 1 insertions, 1 deletions
| diff --git a/rest_framework/response.py b/rest_framework/response.py index 5c02ea50..25b78524 100644 --- a/rest_framework/response.py +++ b/rest_framework/response.py @@ -20,7 +20,7 @@ class Response(SimpleTemplateResponse):      if django.VERSION >= (1, 4):          rendering_attrs = SimpleTemplateResponse.rendering_attrs + ['_closable_objects'] -    def __init__(self, data=None, status=200, +    def __init__(self, data=None, status=None,                   template_name=None, headers=None,                   exception=False, content_type=None):          """ | 
