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
e92002dd
Commit
e92002dd
authored
May 16, 2011
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nested resources now working
parent
47645319
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
7 deletions
+13
-7
djangorestframework/resources.py
+13
-7
No files found.
djangorestframework/resources.py
View file @
e92002dd
...
...
@@ -10,6 +10,7 @@ import inspect
import
re
# TODO: _IgnoreFieldException
def
_model_to_dict
(
instance
,
resource
=
None
):
"""
...
...
@@ -32,9 +33,9 @@ def _model_to_dict(instance, resource=None):
#else:
# fields = set(opts.fields + opts.many_to_many)
fields
=
resource
.
fields
include
=
resource
.
include
exclude
=
resource
.
exclude
fields
=
resource
and
resource
.
fields
or
()
include
=
resource
and
resource
.
include
or
()
exclude
=
resource
and
resource
.
exclude
or
()
extra_fields
=
fields
and
list
(
resource
.
fields
)
or
[]
...
...
@@ -157,8 +158,13 @@ class FormResource(Resource):
On calling validate() this validator may set a `.bound_form_instance` attribute on the
view, which may be used by some renderers.
"""
"""
The form class that should be used for request validation.
"""
form
=
None
def
validate_request
(
self
,
data
,
files
):
"""
Given some content as input return some cleaned, validated content.
...
...
@@ -261,12 +267,12 @@ class ModelResource(FormResource):
If set to ``None`` then the default model form validation will be used.
"""
form
=
None
"""
The model class which this resource maps to.
"""
model
=
None
"""
The list of fields to use on the output.
...
...
@@ -286,7 +292,7 @@ class ModelResource(FormResource):
exclude
=
(
'id'
,
'pk'
)
"""
The list of fields to include. This is only used if ``fields`` is not set.
The list of
extra
fields to include. This is only used if ``fields`` is not set.
"""
include
=
(
'url'
,)
...
...
@@ -342,7 +348,7 @@ class ModelResource(FormResource):
def
url
(
self
,
instance
):
"""
Attempts to reverse resolve the url of the given model instance for this resource.
Requires a ``View`` with ``InstanceMixin`` to have been created for this resource.
This method can be overridden if you need to set the resource url reversing explicitly.
...
...
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