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.core.handlers.wsgi import STATUS_CODE_TEXT
|
||||
import json
|
||||
|
||||
class BaseEmitter(object):
|
||||
|
@ -17,6 +18,7 @@ class TemplatedEmitter(BaseEmitter):
|
|||
context = Context({
|
||||
'content': content,
|
||||
'status': self.status,
|
||||
'reason': STATUS_CODE_TEXT.get(self.status, ''),
|
||||
'headers': self.headers,
|
||||
'resource_name': self.resource.__class__.__name__,
|
||||
'resource_doc': self.resource.__doc__
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
<body>
|
||||
<h1>{{ resource_name }}</h1>
|
||||
<p>{{ resource_doc }}</p>
|
||||
<pre>{% autoescape off %}HTTP Status {{ status }}
|
||||
{% for key, val in headers.items %}{{ key }}: {{ val }}
|
||||
<pre>{% autoescape off %}<b>{{ status }} {{ reason }}</b>
|
||||
{% for key, val in headers.items %}<b>{{ key }}:</b> {{ val }}
|
||||
{% endfor %}
|
||||
{{ content|urlize_quoted_links }}{% endautoescape %} </pre>
|
||||
</body>
|
||||
|
|
Loading…
Reference in New Issue
Block a user