diff options
| author | Sébastien Piquemal | 2012-02-14 10:05:28 +0200 |
|---|---|---|
| committer | Sébastien Piquemal | 2012-02-14 10:05:28 +0200 |
| commit | 821844bb11e5262fb0dfc2fecf2add8fe18d3210 (patch) | |
| tree | 02c16208ac3f6432746bd79693123dd399282d83 /djangorestframework/response.py | |
| parent | b33579a7a18c2cbc6e3789d4a7dc78c82fb0fe80 (diff) | |
| download | django-rest-framework-821844bb11e5262fb0dfc2fecf2add8fe18d3210.tar.bz2 | |
fixed examples, corrected small bugs in the process
Diffstat (limited to 'djangorestframework/response.py')
| -rw-r--r-- | djangorestframework/response.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/djangorestframework/response.py b/djangorestframework/response.py index c5fdccbc..6c42c898 100644 --- a/djangorestframework/response.py +++ b/djangorestframework/response.py @@ -75,7 +75,7 @@ class Response(SimpleTemplateResponse): Returns reason text corresponding to our HTTP response status code. Provided for convenience. """ - return STATUS_CODE_TEXT.get(self.status, '') + return STATUS_CODE_TEXT.get(self.status_code, '') def _determine_accept_list(self): """ @@ -166,5 +166,11 @@ class ImmediateResponse(Response, BaseException): """ A subclass of :class:`Response` used to abort the current request handling. """ - pass + def __str__(self): + """ + Since this class is also an exception it has to provide a sensible + representation for the cases when it is treated as an exception. + """ + return ('%s must be caught in try/except block, ' + 'and returned as a normal HttpResponse' % self.__class__.__name__) |
