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
4e156328
Commit
4e156328
authored
Feb 01, 2011
by
tom christie tom@tomchristie.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated resourceexample with seperate form.py
parent
3a8facdb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
11 deletions
+9
-11
examples/resourceexample/forms.py
+6
-0
examples/resourceexample/urls.py
+1
-1
examples/resourceexample/views.py
+2
-10
No files found.
examples/resourceexample/forms.py
0 → 100644
View file @
4e156328
from
django
import
forms
class
MyForm
(
forms
.
Form
):
foo
=
forms
.
BooleanField
()
bar
=
forms
.
IntegerField
(
help_text
=
'Must be an integer.'
)
baz
=
forms
.
CharField
(
max_length
=
32
,
help_text
=
'Free text. Max length 32 chars.'
)
examples/resourceexample/urls.py
View file @
4e156328
from
django.conf.urls.defaults
import
patterns
,
url
urlpatterns
=
patterns
(
'resourceexample.views'
,
url
(
r'^$'
,
'ExampleResource'
),
url
(
r'^$'
,
'ExampleResource'
),
url
(
r'^(?P<num>[0-9]+)/$'
,
'AnotherExampleResource'
),
)
examples/resourceexample/views.py
View file @
4e156328
from
django
import
forms
from
djangorestframework.resource
import
Resource
from
djangorestframework.response
import
Response
,
status
class
MyForm
(
forms
.
Form
):
foo
=
forms
.
BooleanField
()
bar
=
forms
.
IntegerField
(
help_text
=
'Must be an integer.'
)
baz
=
forms
.
CharField
(
max_length
=
32
,
help_text
=
'Free text. Max length 32 chars.'
)
from
resourceexample.forms
import
MyForm
class
ExampleResource
(
Resource
):
"""A basic read only resource that points to 3 other resources."""
...
...
@@ -16,11 +9,10 @@ class ExampleResource(Resource):
def
get
(
self
,
request
,
auth
):
return
{
"Some other resources"
:
[
self
.
reverse
(
AnotherExampleResource
,
num
=
num
)
for
num
in
range
(
3
)]}
class
AnotherExampleResource
(
Resource
):
"""A basic GET-able/POST-able resource."""
allowed_methods
=
anon_allowed_methods
=
(
'GET'
,
'POST'
)
form
=
MyForm
# Optional form validation on input
form
=
MyForm
# Optional form validation on input (Applies in this case the POST method, but can also apply to PUT)
def
get
(
self
,
request
,
auth
,
num
):
"""Handle GET requests"""
...
...
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