@@ -237,7 +237,7 @@ class ModelResource(FormResource):
...
@@ -237,7 +237,7 @@ class ModelResource(FormResource):
Also provides a :meth:`get_bound_form` method which may be used by some renderers.
Also provides a :meth:`get_bound_form` method which may be used by some renderers.
"""
"""
# Auto-register new ModelResource classes into _model_to_resource
# Auto-register new ModelResource classes into _model_to_resource
#__metaclass__ = _RegisterModelResource
#__metaclass__ = _RegisterModelResource
form=None
form=None
...
@@ -258,21 +258,21 @@ class ModelResource(FormResource):
...
@@ -258,21 +258,21 @@ class ModelResource(FormResource):
fields=None
fields=None
"""
"""
The list of fields to use on the output.
The list of fields to use on the output.
May be any of:
May be any of:
The name of a model field. To view nested resources, give the field as a tuple of ("fieldName", resource) where `resource` may be any of ModelResource reference, the name of a ModelResourc reference as a string or a tuple of strings representing fields on the nested model.
The name of a model field. To view nested resources, give the field as a tuple of ("fieldName", resource) where `resource` may be any of ModelResource reference, the name of a ModelResourc reference as a string or a tuple of strings representing fields on the nested model.
The name of an attribute on the model.
The name of an attribute on the model.
The name of an attribute on the resource.
The name of an attribute on the resource.
The name of a method on the model, with a signature like ``func(self)``.
The name of a method on the model, with a signature like ``func(self)``.
The name of a method on the resource, with a signature like ``func(self, instance)``.
The name of a method on the resource, with a signature like ``func(self, instance)``.
"""
"""
exclude=('id','pk')
exclude=('id','pk')
"""
"""
The list of fields to exclude. This is only used if :attr:`fields` is not set.
The list of fields to exclude. This is only used if :attr:`fields` is not set.
"""
"""
include=('url',)
include=('url',)
"""
"""
...
@@ -294,7 +294,7 @@ class ModelResource(FormResource):
...
@@ -294,7 +294,7 @@ class ModelResource(FormResource):
"""
"""
Given some content as input return some cleaned, validated content.
Given some content as input return some cleaned, validated content.
Raises a :exc:`response.ErrorResponse` with status code 400 (Bad Request) on failure.
Raises a :exc:`response.ErrorResponse` with status code 400 (Bad Request) on failure.
Validation is standard form or model form validation,
Validation is standard form or model form validation,
with an additional constraint that no extra unknown fields may be supplied,
with an additional constraint that no extra unknown fields may be supplied,
and that all fields specified by the fields class attribute must be supplied,
and that all fields specified by the fields class attribute must be supplied,
...
@@ -345,12 +345,12 @@ class ModelResource(FormResource):
...
@@ -345,12 +345,12 @@ class ModelResource(FormResource):
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 :class:`mixins.InstanceMixin` to have been created for this resource.
Requires a ``View`` with :class:`mixins.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.
"""
"""
ifnothasattr(self,'view_callable'):
ifnothasattr(self,'view_callable'):
raise_SkipField
raise_SkipField
# dis does teh magicks...
# dis does teh magicks...
urlconf=get_urlconf()
urlconf=get_urlconf()
...
@@ -393,7 +393,7 @@ class ModelResource(FormResource):
...
@@ -393,7 +393,7 @@ class ModelResource(FormResource):
# The browsers usually strip the parameter completely. A hack to avoid this, and therefore being able to submit an empty select multiple, is to submit a value that tells the server that the list is empty ::
# The browsers usually strip the parameter completely. A hack to avoid this, and therefore being able to submit an empty select multiple, is to submit a value that tells the server that the list is empty ::
1. A basic example using the [Resource](http://django-rest-framework.org/library/resource.html) class.
1. A basic example using the [Resource](http://django-rest-framework.org/library/resource.html) class.
2. A basic example using the [ModelResource](http://django-rest-framework.org/library/modelresource.html) class.
2. A basic example using the [ModelResource](http://django-rest-framework.org/library/modelresource.html) class.
3. An basic example using Django 1.3's [class based views](http://docs.djangoproject.com/en/dev/topics/class-based-views/) and djangorestframework's [RendererMixin](http://django-rest-framework.org/library/renderers.html).
3. An basic example using Django 1.3's [class based views](http://docs.djangoproject.com/en/dev/topics/class-based-views/) and djangorestframework's [RendererMixin](http://django-rest-framework.org/library/renderers.html).