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
ff6e7832
Commit
ff6e7832
authored
Jun 15, 2011
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update some examples
parent
7dcb851c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
0 deletions
+35
-0
examples/blogpost/resources.py
+28
-0
examples/modelresourceexample/resources.py
+7
-0
examples/modelresourceexample/views.py
+0
-0
No files found.
examples/blogpost/resources.py
0 → 100644
View file @
ff6e7832
from
django.core.urlresolvers
import
reverse
from
djangorestframework.resources
import
ModelResource
from
blogpost.models
import
BlogPost
,
Comment
class
BlogPostResource
(
ModelResource
):
"""
A Blog Post has a *title* and *content*, and can be associated with zero or more comments.
"""
model
=
BlogPost
fields
=
(
'created'
,
'title'
,
'slug'
,
'content'
,
'url'
,
'comments'
)
ordering
=
(
'-created'
,)
def
comments
(
self
,
instance
):
return
reverse
(
'comments'
,
kwargs
=
{
'blogpost'
:
instance
.
key
})
class
CommentResource
(
ModelResource
):
"""
A Comment is associated with a given Blog Post and has a *username* and *comment*, and optionally a *rating*.
"""
model
=
Comment
fields
=
(
'username'
,
'comment'
,
'created'
,
'rating'
,
'url'
,
'blogpost'
)
ordering
=
(
'-created'
,)
def
blogpost
(
self
,
instance
):
return
reverse
(
'blog-post'
,
kwargs
=
{
'key'
:
instance
.
blogpost
.
key
})
\ No newline at end of file
examples/modelresourceexample/resources.py
0 → 100644
View file @
ff6e7832
from
djangorestframework.resources
import
ModelResource
from
modelresourceexample.models
import
MyModel
class
MyModelResource
(
ModelResource
):
model
=
MyModel
fields
=
(
'foo'
,
'bar'
,
'baz'
,
'url'
)
ordering
=
(
'created'
,)
examples/modelresourceexample/views.py
deleted
100644 → 0
View file @
7dcb851c
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