mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-16 19:41:06 +03:00
nested resources now working
This commit is contained in:
parent
47645319c9
commit
e92002ddde
|
@ -10,6 +10,7 @@ import inspect
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: _IgnoreFieldException
|
||||||
|
|
||||||
def _model_to_dict(instance, resource=None):
|
def _model_to_dict(instance, resource=None):
|
||||||
"""
|
"""
|
||||||
|
@ -32,9 +33,9 @@ def _model_to_dict(instance, resource=None):
|
||||||
#else:
|
#else:
|
||||||
# fields = set(opts.fields + opts.many_to_many)
|
# fields = set(opts.fields + opts.many_to_many)
|
||||||
|
|
||||||
fields = resource.fields
|
fields = resource and resource.fields or ()
|
||||||
include = resource.include
|
include = resource and resource.include or ()
|
||||||
exclude = resource.exclude
|
exclude = resource and resource.exclude or ()
|
||||||
|
|
||||||
extra_fields = fields and list(resource.fields) 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
|
On calling validate() this validator may set a `.bound_form_instance` attribute on the
|
||||||
view, which may be used by some renderers.
|
view, which may be used by some renderers.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
"""
|
||||||
|
The form class that should be used for request validation.
|
||||||
|
"""
|
||||||
form = None
|
form = None
|
||||||
|
|
||||||
|
|
||||||
def validate_request(self, data, files):
|
def validate_request(self, data, files):
|
||||||
"""
|
"""
|
||||||
Given some content as input return some cleaned, validated content.
|
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.
|
If set to ``None`` then the default model form validation will be used.
|
||||||
"""
|
"""
|
||||||
form = None
|
form = None
|
||||||
|
|
||||||
"""
|
"""
|
||||||
The model class which this resource maps to.
|
The model class which this resource maps to.
|
||||||
"""
|
"""
|
||||||
model = None
|
model = None
|
||||||
|
|
||||||
"""
|
"""
|
||||||
The list of fields to use on the output.
|
The list of fields to use on the output.
|
||||||
|
|
||||||
|
@ -286,7 +292,7 @@ class ModelResource(FormResource):
|
||||||
exclude = ('id', 'pk')
|
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',)
|
include = ('url',)
|
||||||
|
|
||||||
|
@ -342,7 +348,7 @@ class ModelResource(FormResource):
|
||||||
def url(self, instance):
|
def url(self, instance):
|
||||||
"""
|
"""
|
||||||
Attempts to reverse resolve the url of the given model instance for this resource.
|
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.
|
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.
|
This method can be overridden if you need to set the resource url reversing explicitly.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user