diff options
| author | Tom Christie | 2012-02-23 08:58:10 +0000 |
|---|---|---|
| committer | Tom Christie | 2012-02-23 08:58:10 +0000 |
| commit | 2b59df004a5bb7449aa4c07277ac846c330a79f7 (patch) | |
| tree | 3a5e20948d3cd0ea1ca4d25ff35d970646722a30 /djangorestframework/resources.py | |
| parent | 8e0b9e55ecb0733369918d4562ba38ba505cdfe8 (diff) | |
| download | django-rest-framework-2b59df004a5bb7449aa4c07277ac846c330a79f7.tar.bz2 | |
reverse takes request as a kwarg for compatibility with django's reverse
Diffstat (limited to 'djangorestframework/resources.py')
| -rw-r--r-- | djangorestframework/resources.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/djangorestframework/resources.py b/djangorestframework/resources.py index 2b84ee09..71c4d2b9 100644 --- a/djangorestframework/resources.py +++ b/djangorestframework/resources.py @@ -10,7 +10,8 @@ from djangorestframework.utils import as_tuple class BaseResource(Serializer): """ - Base class for all Resource classes, which simply defines the interface they provide. + Base class for all Resource classes, which simply defines the interface + they provide. """ fields = None include = None @@ -19,11 +20,13 @@ class BaseResource(Serializer): def __init__(self, view=None, depth=None, stack=[], **kwargs): super(BaseResource, self).__init__(depth, stack, **kwargs) self.view = view + self.request = view.request def validate_request(self, data, files=None): """ Given the request content return the cleaned, validated content. - Typically raises a :exc:`response.ErrorResponse` with status code 400 (Bad Request) on failure. + Typically raises a :exc:`response.ErrorResponse` with status code 400 + (Bad Request) on failure. """ return data @@ -37,7 +40,8 @@ class BaseResource(Serializer): class Resource(BaseResource): """ A Resource determines how a python object maps to some serializable data. - Objects that a resource can act on include plain Python object instances, Django Models, and Django QuerySets. + Objects that a resource can act on include plain Python object instances, + Django Models, and Django QuerySets. """ # The model attribute refers to the Django Model which this Resource maps to. @@ -355,7 +359,9 @@ class ModelResource(FormResource): instance_attrs[param] = attr try: - return reverse(self.view_callable[0], self.view.request, kwargs=instance_attrs) + return reverse(self.view_callable[0], + kwargs=instance_attrs, + request=self.view.request) except NoReverseMatch: pass raise _SkipField |
