@@ -237,7 +237,7 @@ class ModelResource(FormResource):
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
form=None
...
...
@@ -258,21 +258,21 @@ class ModelResource(FormResource):
fields=None
"""
The list of fields to use on the output.
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 an attribute on the model.
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 resource, with a signature like ``func(self, instance)``.
"""
exclude=('id','pk')
"""
The list of fields to exclude. This is only used if :attr:`fields` is not set.
"""
include=('url',)
"""
...
...
@@ -294,7 +294,7 @@ class ModelResource(FormResource):
"""
Given some content as input return some cleaned, validated content.
Raises a :exc:`response.ErrorResponse` with status code 400 (Bad Request) on failure.
Validation is standard form or model form validation,
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,
...
...
@@ -345,12 +345,12 @@ class ModelResource(FormResource):
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.
This method can be overridden if you need to set the resource url reversing explicitly.
"""
ifnothasattr(self,'view_callable'):
raise_SkipField
raise_SkipField
# dis does teh magicks...
urlconf=get_urlconf()
...
...
@@ -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 ::
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.
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).