mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-10 19:56:59 +03:00
Nicer formatting of status
This commit is contained in:
parent
abb55a4909
commit
a78f578475
|
@ -1,4 +1,5 @@
|
||||||
from django.template import Context, loader
|
from django.template import Context, loader
|
||||||
|
from django.core.handlers.wsgi import STATUS_CODE_TEXT
|
||||||
import json
|
import json
|
||||||
|
|
||||||
class BaseEmitter(object):
|
class BaseEmitter(object):
|
||||||
|
@ -17,6 +18,7 @@ class TemplatedEmitter(BaseEmitter):
|
||||||
context = Context({
|
context = Context({
|
||||||
'content': content,
|
'content': content,
|
||||||
'status': self.status,
|
'status': self.status,
|
||||||
|
'reason': STATUS_CODE_TEXT.get(self.status, ''),
|
||||||
'headers': self.headers,
|
'headers': self.headers,
|
||||||
'resource_name': self.resource.__class__.__name__,
|
'resource_name': self.resource.__class__.__name__,
|
||||||
'resource_doc': self.resource.__doc__
|
'resource_doc': self.resource.__doc__
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
<body>
|
<body>
|
||||||
<h1>{{ resource_name }}</h1>
|
<h1>{{ resource_name }}</h1>
|
||||||
<p>{{ resource_doc }}</p>
|
<p>{{ resource_doc }}</p>
|
||||||
<pre>{% autoescape off %}HTTP Status {{ status }}
|
<pre>{% autoescape off %}<b>{{ status }} {{ reason }}</b>
|
||||||
{% for key, val in headers.items %}{{ key }}: {{ val }}
|
{% for key, val in headers.items %}<b>{{ key }}:</b> {{ val }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{{ content|urlize_quoted_links }}{% endautoescape %} </pre>
|
{{ content|urlize_quoted_links }}{% endautoescape %} </pre>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user