Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
b8559c61
Commit
b8559c61
authored
Sep 07, 2012
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing up browseable API for rest framework 2
parent
f1dc9be5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
40 deletions
+46
-40
djangorestframework/renderers.py
+2
-0
djangorestframework/templates/djangorestframework/api.txt
+1
-1
djangorestframework/templates/djangorestframework/base.html
+43
-39
No files found.
djangorestframework/renderers.py
View file @
b8559c61
...
...
@@ -10,6 +10,7 @@ from django.template import RequestContext, loader
from
django.utils
import
simplejson
as
json
from
djangorestframework.compat
import
yaml
from
djangorestframework.settings
import
api_settings
from
djangorestframework.utils
import
dict2xml
from
djangorestframework.utils
import
encoders
from
djangorestframework.utils.breadcrumbs
import
get_breadcrumbs
...
...
@@ -344,6 +345,7 @@ class DocumentingTemplateRenderer(BaseRenderer):
'post_form'
:
post_form_instance
,
'FORMAT_PARAM'
:
self
.
_FORMAT_QUERY_PARAM
,
'METHOD_PARAM'
:
getattr
(
self
.
view
,
'_METHOD_PARAM'
,
None
),
'api_settings'
:
api_settings
})
ret
=
template
.
render
(
context
)
...
...
djangorestframework/templates/djangorestframework/api.txt
View file @
b8559c61
...
...
@@ -2,7 +2,7 @@
{{ description }}
HTTP
/1.0
{{ response.status }} {{ response.status_text }}
HTTP {{ response.status }} {{ response.status_text }}
{% for key, val in response.headers.items %}{{ key }}: {{ val }}
{% endfor %}
{{ content }}{% endautoescape %}
djangorestframework/templates/djangorestframework/base.html
View file @
b8559c61
{% load url from future %}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
{% load urlize_quoted_links %}
{% load add_query_param %}
{% load optional_login %}
{% load static %}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
>
<head>
<link
rel=
"stylesheet"
type=
"text/css"
href=
'{% get_static_prefix %}djangorestframework/css/style.css'
/>
{% block extrastyle %}{% endblock %}
<title>
{% block title %}Django REST framework - {{ name }}{% endblock %}
</title>
{% block extrahead %}{% endblock %}
<head>
<link
rel=
"stylesheet"
type=
"text/css"
href=
'{% get_static_prefix %}djangorestframework/css/style.css'
/>
{% block extrastyle %}{% endblock %}
<title>
{% block title %}Django REST framework - {{ name }}{% endblock %}
</title>
{% block extrahead %}{% endblock %}
{% block blockbots %}
<meta
name=
"robots"
content=
"NONE,NOARCHIVE"
/>
{% endblock %}
</head>
<body
class=
"{% block bodyclass %}{% endblock %}"
>
...
...
@@ -37,19 +37,19 @@
<div
class=
"breadcrumbs"
>
{% block breadcrumbs %}
{% for breadcrumb_name, breadcrumb_url in breadcrumblist %}
<a
href=
"{{ breadcrumb_url }}"
>
{{ breadcrumb_name }}
</a>
{% if not forloop.last %}
›
{% endif %}
{% endfor %}
{% endblock %}
</div>
<a
href=
"{{ breadcrumb_url }}"
>
{{ breadcrumb_name }}
</a>
{% if not forloop.last %}
›
{% endif %}
{% endfor %}
{% endblock %}
</div>
<!-- Content -->
<div
id=
"content"
class=
"{% block coltype %}colM{% endblock %}"
>
<!-- Content -->
<div
id=
"content"
class=
"{% block coltype %}colM{% endblock %}"
>
{% if 'OPTIONS' in allowed_methods %}
{% if 'OPTIONS' in allowed_methods
and api_settings.FORM_METHOD_OVERRIDE
%}
<form
action=
"{{ request.get_full_path }}"
method=
"post"
>
{% csrf_token %}
<input
type=
"hidden"
name=
"{{
METHOD_PARAM
}}"
value=
"OPTIONS"
/>
<input
type=
"submit"
value=
"OPTIONS"
class=
"default"
/>
{% csrf_token %}
<input
type=
"hidden"
name=
"{{
api_settings.FORM_METHOD_OVERRIDE
}}"
value=
"OPTIONS"
/>
<input
type=
"submit"
value=
"OPTIONS"
class=
"default"
/>
</form>
{% endif %}
...
...
@@ -57,7 +57,7 @@
<h1>
{{ name }}
</h1>
<p>
{{ description }}
</p>
<div
class=
'module'
>
<pre><b>
{{ response.status_code }} {{ response.status_text }}
</b>
{% autoescape off %}
<pre><b>
HTTP
{{ response.status_code }} {{ response.status_text }}
</b>
{% autoescape off %}
{% for key, val in response.items %}
<b>
{{ key }}:
</b>
{{ val|urlize_quoted_links }}
{% endfor %}
{{ content|urlize_quoted_links }}
</pre>
{% endautoescape %}
</div>
...
...
@@ -78,21 +78,24 @@
</form>
{% endif %}
{% comment %}
DROP POST/PUT/DELETE until the forms are working with REST framework 2
{# Only display the POST/PUT/DELETE forms if method tunneling via POST forms is enabled and the user has permissions on this view. #}
{% if
METHOD_PARAM and
response.status_code != 403 %}
{% if response.status_code != 403 %}
{% if 'POST' in allowed_methods %}
<form
action=
"{{ request.get_full_path }}"
method=
"
post
"
{%
if
post_form
.
is_multipart
%}
enctype=
"multipart/form-data"
{%
endif
%}
>
<form
action=
"{{ request.get_full_path }}"
method=
"
POST
"
{%
if
post_form
.
is_multipart
%}
enctype=
"multipart/form-data"
{%
endif
%}
>
<fieldset
class=
'module aligned'
>
<h2>
POST {{ name }}
</h2>
{% csrf_token %}
{{ post_form.non_field_errors }}
{% csrf_token %}
{{ post_form.non_field_errors }}
{% for field in post_form %}
<div
class=
'form-row'
>
{{ field.label_tag }}
{{ field }}
<span
class=
'help'
>
{{ field.help_text }}
</span>
{{ field.errors }}
{{ field.label_tag }}
{{ field }}
<span
class=
'help'
>
{{ field.help_text }}
</span>
{{ field.errors }}
</div>
{% endfor %}
<div
class=
'submit-row'
style=
'margin: 0; border: 0'
>
...
...
@@ -102,42 +105,43 @@
</form>
{% endif %}
{% if 'PUT' in allowed_methods %}
<form
action=
"{{ request.get_full_path }}"
method=
"
post
"
{%
if
put_form
.
is_multipart
%}
enctype=
"multipart/form-data"
{%
endif
%}
>
{% if 'PUT' in allowed_methods
and api_settings.FORM_METHOD_OVERRIDE
%}
<form
action=
"{{ request.get_full_path }}"
method=
"
POST
"
{%
if
put_form
.
is_multipart
%}
enctype=
"multipart/form-data"
{%
endif
%}
>
<fieldset
class=
'module aligned'
>
<h2>
PUT {{ name }}
</h2>
<input
type=
"hidden"
name=
"{{
METHOD_PARAM
}}"
value=
"PUT"
/>
<input
type=
"hidden"
name=
"{{
api_settings.FORM_METHOD_OVERRIDE
}}"
value=
"PUT"
/>
{% csrf_token %}
{{ put_form.non_field_errors }}
{% for field in put_form %}
<div
class=
'form-row'
>
{{ field.label_tag }}
{{ field }}
<span
class=
'help'
>
{{ field.help_text }}
</span>
{{ field.errors }}
{{ field.label_tag }}
{{ field }}
<span
class=
'help'
>
{{ field.help_text }}
</span>
{{ field.errors }}
</div>
{% endfor %}
<div
class=
'submit-row'
style=
'margin: 0; border: 0'
>
<input
type=
"submit"
value=
"PUT"
class=
"default"
/>
<input
type=
"submit"
value=
"PUT"
class=
"default"
/>
</div>
</fieldset>
</form>
{% endif %}
{% if 'DELETE' in allowed_methods %}
<form
action=
"{{ request.get_full_path }}"
method=
"
post
"
>
{% if 'DELETE' in allowed_methods
and api_settings.FORM_METHOD_OVERRIDE
%}
<form
action=
"{{ request.get_full_path }}"
method=
"
POST
"
>
<fieldset
class=
'module aligned'
>
<h2>
DELETE {{ name }}
</h2>
{% csrf_token %}
<input
type=
"hidden"
name=
"{{
METHOD_PARAM
}}"
value=
"DELETE"
/>
<input
type=
"hidden"
name=
"{{
api_settings.FORM_METHOD_OVERRIDE
}}"
value=
"DELETE"
/>
<div
class=
'submit-row'
style=
'margin: 0; border: 0'
>
<input
type=
"submit"
value=
"DELETE"
class=
"default"
/>
<input
type=
"submit"
value=
"DELETE"
class=
"default"
/>
</div>
</fieldset>
</form>
{% endif %}
{% endif %}
{% endcomment %}
</div>
<!-- END content-main -->
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment