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
94401b43
Commit
94401b43
authored
Oct 09, 2012
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Flesh out quickstart guide and make some style tweaks
parent
7c4d50f6
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
15 deletions
+64
-15
docs/images/quickstart.png
+0
-0
docs/tutorial/quickstart.md
+40
-0
mkdocs.py
+16
-9
rest_framework/static/rest_framework/css/default.css
+4
-0
rest_framework/templates/rest_framework/base.html
+4
-6
No files found.
docs/images/quickstart.png
0 → 100644
View file @
94401b43
38.1 KB
docs/tutorial/quickstart.md
View file @
94401b43
...
@@ -131,3 +131,42 @@ We'd also like to set a few global settings. We'd like to turn on pagination, a
...
@@ -131,3 +131,42 @@ We'd also like to set a few global settings. We'd like to turn on pagination, a
}
}
Okay, that's us done.
Okay, that's us done.
---
## Testing our API
We can now access our API, both from the command-line, using tools like
`curl`
...
bash: curl -H 'Accept: application/json; indent=4' -u admin:password http://127.0.0.1:8000/users/
{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"email": "admin@example.com",
"groups": [],
"url": "http://127.0.0.1:8000/users/1/",
"username": "admin"
},
{
"email": "tom@example.com",
"groups": [],
"url": "http://127.0.0.1:8000/users/2/",
"username": "tom"
}
]
}
Or directly through the browser...
![
Quick start image
][
image
]
Great, that was easy!
If you want to get a more in depth understanding of how REST framework fits together head on over to
[
the tutorial
][
tutorial
]
, or start browsing the
[
API guide
][
guide
]
.
[
image
]:
../images/quickstart.png
[
tutorial
]:
1-serialization.md
[
guide
]:
../#api-guide
\ No newline at end of file
mkdocs.py
View file @
94401b43
...
@@ -37,12 +37,25 @@ for static in ['css', 'js', 'img']:
...
@@ -37,12 +37,25 @@ for static in ['css', 'js', 'img']:
shutil
.
copytree
(
source
,
target
)
shutil
.
copytree
(
source
,
target
)
for
(
dirpath
,
dirnames
,
filenames
)
in
os
.
walk
(
docs_dir
):
for
(
dirpath
,
dirnames
,
filenames
)
in
os
.
walk
(
docs_dir
):
relative_dir
=
dirpath
.
replace
(
docs_dir
,
''
)
.
lstrip
(
os
.
path
.
sep
)
build_dir
=
os
.
path
.
join
(
html_dir
,
relative_dir
)
if
not
os
.
path
.
exists
(
build_dir
):
os
.
makedirs
(
build_dir
)
for
filename
in
filenames
:
for
filename
in
filenames
:
if
not
filename
.
endswith
(
'.md'
):
path
=
os
.
path
.
join
(
dirpath
,
filename
)
if
filename
.
endswith
(
'.png'
):
output_path
=
os
.
path
.
join
(
build_dir
,
filename
)
shutil
.
copy
(
path
,
output_path
)
continue
elif
not
filename
.
endswith
(
'.md'
):
continue
continue
output_path
=
os
.
path
.
join
(
build_dir
,
filename
[:
-
3
]
+
'.html'
)
toc
=
''
toc
=
''
text
=
open
(
os
.
path
.
join
(
dirpath
,
filename
)
,
'r'
)
.
read
()
.
decode
(
'utf-8'
)
text
=
open
(
path
,
'r'
)
.
read
()
.
decode
(
'utf-8'
)
for
line
in
text
.
splitlines
():
for
line
in
text
.
splitlines
():
if
line
.
startswith
(
'# '
):
if
line
.
startswith
(
'# '
):
title
=
line
[
2
:]
.
strip
()
title
=
line
[
2
:]
.
strip
()
...
@@ -60,16 +73,10 @@ for (dirpath, dirnames, filenames) in os.walk(docs_dir):
...
@@ -60,16 +73,10 @@ for (dirpath, dirnames, filenames) in os.walk(docs_dir):
content
=
markdown
.
markdown
(
text
,
[
'headerid'
])
content
=
markdown
.
markdown
(
text
,
[
'headerid'
])
relative_dir
=
dirpath
.
replace
(
docs_dir
,
''
)
.
lstrip
(
os
.
path
.
sep
)
build_dir
=
os
.
path
.
join
(
html_dir
,
relative_dir
)
build_file
=
os
.
path
.
join
(
build_dir
,
filename
[:
-
3
]
+
'.html'
)
if
not
os
.
path
.
exists
(
build_dir
):
os
.
makedirs
(
build_dir
)
output
=
page
.
replace
(
'{{ content }}'
,
content
)
.
replace
(
'{{ toc }}'
,
toc
)
.
replace
(
'{{ base_url }}'
,
base_url
)
.
replace
(
'{{ suffix }}'
,
suffix
)
.
replace
(
'{{ index }}'
,
index
)
output
=
page
.
replace
(
'{{ content }}'
,
content
)
.
replace
(
'{{ toc }}'
,
toc
)
.
replace
(
'{{ base_url }}'
,
base_url
)
.
replace
(
'{{ suffix }}'
,
suffix
)
.
replace
(
'{{ index }}'
,
index
)
output
=
output
.
replace
(
'{{ page_id }}'
,
filename
[:
-
3
])
output
=
output
.
replace
(
'{{ page_id }}'
,
filename
[:
-
3
])
output
=
re
.
sub
(
r'a href="([^"]*)\.md"'
,
r'a href="\1
%
s"'
%
suffix
,
output
)
output
=
re
.
sub
(
r'a href="([^"]*)\.md"'
,
r'a href="\1
%
s"'
%
suffix
,
output
)
output
=
re
.
sub
(
r'<pre><code>:::bash'
,
r'<pre class="prettyprint lang-bsh">'
,
output
)
output
=
re
.
sub
(
r'<pre><code>:::bash'
,
r'<pre class="prettyprint lang-bsh">'
,
output
)
output
=
re
.
sub
(
r'<pre>'
,
r'<pre class="prettyprint lang-py">'
,
output
)
output
=
re
.
sub
(
r'<pre>'
,
r'<pre class="prettyprint lang-py">'
,
output
)
output
=
re
.
sub
(
r'<a class="github" href="([^"]*)"></a>'
,
code_label
,
output
)
output
=
re
.
sub
(
r'<a class="github" href="([^"]*)"></a>'
,
code_label
,
output
)
open
(
build_file
,
'w'
)
.
write
(
output
.
encode
(
'utf-8'
))
open
(
output_path
,
'w'
)
.
write
(
output
.
encode
(
'utf-8'
))
rest_framework/static/rest_framework/css/default.css
View file @
94401b43
...
@@ -19,6 +19,10 @@ h2, h3 {
...
@@ -19,6 +19,10 @@ h2, h3 {
padding-right
:
0.25em
;
padding-right
:
0.25em
;
}
}
.version
{
font-size
:
70%
;
}
.format-option
{
.format-option
{
font-family
:
Menlo
,
Consolas
,
"Andale Mono"
,
"Lucida Console"
,
monospace
;
font-family
:
Menlo
,
Consolas
,
"Andale Mono"
,
"Lucida Console"
,
monospace
;
}
}
...
...
rest_framework/templates/rest_framework/base.html
View file @
94401b43
...
@@ -39,7 +39,7 @@
...
@@ -39,7 +39,7 @@
{% if user.is_authenticated %}
{% if user.is_authenticated %}
<li
class=
"dropdown"
>
<li
class=
"dropdown"
>
<a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
>
<a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
>
Logged in as
{{ user }}
{{ user }}
<b
class=
"caret"
></b>
<b
class=
"caret"
></b>
</a>
</a>
<ul
class=
"dropdown-menu"
>
<ul
class=
"dropdown-menu"
>
...
@@ -128,7 +128,6 @@
...
@@ -128,7 +128,6 @@
<div
class=
"well"
>
<div
class=
"well"
>
<form
action=
"{{ request.get_full_path }}"
method=
"POST"
{%
if
post_form
.
is_multipart
%}
enctype=
"multipart/form-data"
{%
endif
%}
class=
"form-horizontal"
>
<form
action=
"{{ request.get_full_path }}"
method=
"POST"
{%
if
post_form
.
is_multipart
%}
enctype=
"multipart/form-data"
{%
endif
%}
class=
"form-horizontal"
>
<fieldset>
<fieldset>
<h2>
POST: {{ name }}
</h2>
{% csrf_token %}
{% csrf_token %}
{{ post_form.non_field_errors }}
{{ post_form.non_field_errors }}
{% for field in post_form %}
{% for field in post_form %}
...
@@ -153,7 +152,6 @@
...
@@ -153,7 +152,6 @@
<div
class=
"well"
>
<div
class=
"well"
>
<form
action=
"{{ request.get_full_path }}"
method=
"POST"
{%
if
put_form
.
is_multipart
%}
enctype=
"multipart/form-data"
{%
endif
%}
class=
"form-horizontal"
>
<form
action=
"{{ request.get_full_path }}"
method=
"POST"
{%
if
put_form
.
is_multipart
%}
enctype=
"multipart/form-data"
{%
endif
%}
class=
"form-horizontal"
>
<fieldset>
<fieldset>
<h2>
PUT: {{ name }}
</h2>
<input
type=
"hidden"
name=
"{{ api_settings.FORM_METHOD_OVERRIDE }}"
value=
"PUT"
/>
<input
type=
"hidden"
name=
"{{ api_settings.FORM_METHOD_OVERRIDE }}"
value=
"PUT"
/>
{% csrf_token %}
{% csrf_token %}
{{ put_form.non_field_errors }}
{{ put_form.non_field_errors }}
...
@@ -191,9 +189,9 @@
...
@@ -191,9 +189,9 @@
</div>
<!-- ./wrapper -->
</div>
<!-- ./wrapper -->
{% block footer %}
{% block footer %}
<div
id=
"footer"
>
<
!--<
div id="footer">
<a
class=
"powered-by"
href=
'http://django-rest-framework.org'
>
Django REST framework
</a>
<span
class=
"version"
>
{{ version }}
</span>
<a class="powered-by" href='http://django-rest-framework.org'>Django REST framework</a>
</div>
</div>
-->
{% endblock %}
{% endblock %}
{% block script %}
{% block script %}
...
...
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