aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--djangorestframework/mixins.py4
-rw-r--r--djangorestframework/renderers.py2
-rw-r--r--djangorestframework/templates/renderer.html4
-rw-r--r--djangorestframework/tests/mixins.py2
-rw-r--r--djangorestframework/tests/response.py3
-rw-r--r--examples/mixin/urls.py3
-rw-r--r--examples/objectstore/views.py4
-rw-r--r--examples/pygments_api/views.py3
-rw-r--r--examples/requestexample/urls.py4
-rw-r--r--examples/requestexample/views.py2
-rw-r--r--examples/views.py8
11 files changed, 21 insertions, 18 deletions
diff --git a/djangorestframework/mixins.py b/djangorestframework/mixins.py
index 516a0f4b..43dce870 100644
--- a/djangorestframework/mixins.py
+++ b/djangorestframework/mixins.py
@@ -372,7 +372,7 @@ class ReadModelMixin(ModelMixin):
except model.DoesNotExist:
raise ImmediateResponse(status=status.HTTP_404_NOT_FOUND)
- return self.model_instance
+ return Response(self.model_instance)
class CreateModelMixin(ModelMixin):
@@ -428,7 +428,7 @@ class UpdateModelMixin(ModelMixin):
# TODO: update on the url of a non-existing resource url doesn't work
# correctly at the moment - will end up with a new url
try:
- self.model_instance = self.get_instance(*query_kwargs)
+ self.model_instance = self.get_instance(**query_kwargs)
for (key, val) in self.CONTENT.items():
setattr(self.model_instance, key, val)
diff --git a/djangorestframework/renderers.py b/djangorestframework/renderers.py
index 4e8158aa..08022c7c 100644
--- a/djangorestframework/renderers.py
+++ b/djangorestframework/renderers.py
@@ -355,7 +355,7 @@ class DocumentingTemplateRenderer(BaseRenderer):
'login_url': login_url,
'logout_url': logout_url,
'FORMAT_PARAM': self._FORMAT_QUERY_PARAM,
- 'METHOD_PARAM': getattr(self.view, '_METHOD_PARAM', None),
+ 'METHOD_PARAM': getattr(self.view.request, '_METHOD_PARAM', None),
'ADMIN_MEDIA_PREFIX': getattr(settings, 'ADMIN_MEDIA_PREFIX', None),
})
diff --git a/djangorestframework/templates/renderer.html b/djangorestframework/templates/renderer.html
index e396a58f..8b5c77c7 100644
--- a/djangorestframework/templates/renderer.html
+++ b/djangorestframework/templates/renderer.html
@@ -41,7 +41,7 @@
<h1>{{ name }}</h1>
<p>{{ description }}</p>
<div class='module'>
- <pre><b>{{ response.status }} {{ response.status_text }}</b>{% autoescape off %}
+ <pre><b>{{ response.status_code }} {{ response.status_text }}</b>{% autoescape off %}
{% for key, val in response.headers.items %}<b>{{ key }}:</b> {{ val|urlize_quoted_links }}
{% endfor %}
{{ content|urlize_quoted_links }}</pre>{% endautoescape %}</div>
@@ -63,7 +63,7 @@
{% endif %}
{# Only display the POST/PUT/DELETE forms if method tunneling via POST forms is enabled and the user has permissions on this view. #}
- {% if METHOD_PARAM and response.status != 403 %}
+ {% if METHOD_PARAM and response.status_code != 403 %}
{% if 'POST' in view.allowed_methods %}
<form action="{{ request.get_full_path }}" method="post" {% if post_form.is_multipart %}enctype="multipart/form-data"{% endif %}>
diff --git a/djangorestframework/tests/mixins.py b/djangorestframework/tests/mixins.py
index 187ce719..3f5835aa 100644
--- a/djangorestframework/tests/mixins.py
+++ b/djangorestframework/tests/mixins.py
@@ -31,7 +31,7 @@ class TestModelRead(TestModelsTestCase):
mixin.resource = GroupResource
response = mixin.get(request, id=group.id)
- self.assertEquals(group.name, response.name)
+ self.assertEquals(group.name, response.raw_content.name)
def test_read_404(self):
class GroupResource(ModelResource):
diff --git a/djangorestframework/tests/response.py b/djangorestframework/tests/response.py
index b8cc5c1b..95603680 100644
--- a/djangorestframework/tests/response.py
+++ b/djangorestframework/tests/response.py
@@ -139,7 +139,8 @@ class MockView(ResponseMixin, DjangoView):
def get(self, request, **kwargs):
response = Response(DUMMYCONTENT, status=DUMMYSTATUS)
- return self.prepare_response(response)
+ self.response = self.prepare_response(response)
+ return self.response
class HTMLView(View):
diff --git a/examples/mixin/urls.py b/examples/mixin/urls.py
index 6e9e497e..58cf370c 100644
--- a/examples/mixin/urls.py
+++ b/examples/mixin/urls.py
@@ -15,7 +15,8 @@ class ExampleView(ResponseMixin, View):
def get(self, request):
response = Response({'description': 'Some example content',
'url': reverse('mixin-view')}, status=200)
- return self.prepare_response(response)
+ self.response = self.prepare_response(response)
+ return self.response
urlpatterns = patterns('',
diff --git a/examples/objectstore/views.py b/examples/objectstore/views.py
index 47f5147a..ae545394 100644
--- a/examples/objectstore/views.py
+++ b/examples/objectstore/views.py
@@ -67,7 +67,7 @@ class StoredObject(View):
"""
pathname = os.path.join(OBJECT_STORE_DIR, key)
if not os.path.exists(pathname):
- return Response(status.HTTP_404_NOT_FOUND)
+ return Response(status=status.HTTP_404_NOT_FOUND)
return Response(pickle.load(open(pathname, 'rb')))
def put(self, request, key):
@@ -84,6 +84,6 @@ class StoredObject(View):
"""
pathname = os.path.join(OBJECT_STORE_DIR, key)
if not os.path.exists(pathname):
- return Response(status.HTTP_404_NOT_FOUND)
+ return Response(status=status.HTTP_404_NOT_FOUND)
os.remove(pathname)
return Response()
diff --git a/examples/pygments_api/views.py b/examples/pygments_api/views.py
index 44dd2caa..d59a52c0 100644
--- a/examples/pygments_api/views.py
+++ b/examples/pygments_api/views.py
@@ -81,7 +81,8 @@ class PygmentsRoot(View):
remove_oldest_files(HIGHLIGHTED_CODE_DIR, MAX_FILES)
- return Response(status.HTTP_201_CREATED, headers={'Location': reverse('pygments-instance', args=[unique_id])})
+ self.headers['Location'] = reverse('pygments-instance', args=[unique_id])
+ return Response(status.HTTP_201_CREATED)
class PygmentsInstance(View):
diff --git a/examples/requestexample/urls.py b/examples/requestexample/urls.py
index 3c31e4a9..d644a599 100644
--- a/examples/requestexample/urls.py
+++ b/examples/requestexample/urls.py
@@ -1,9 +1,9 @@
from django.conf.urls.defaults import patterns, url
from requestexample.views import RequestExampleView, EchoRequestContentView
-from examples.views import MockView
+from examples.views import ProxyView
urlpatterns = patterns('',
url(r'^$', RequestExampleView.as_view(), name='request-example'),
- url(r'^content$', MockView.as_view(view_class=EchoRequestContentView), name='request-content'),
+ url(r'^content$', ProxyView.as_view(view_class=EchoRequestContentView), name='request-content'),
)
diff --git a/examples/requestexample/views.py b/examples/requestexample/views.py
index 876db864..b5d2c1e7 100644
--- a/examples/requestexample/views.py
+++ b/examples/requestexample/views.py
@@ -25,7 +25,7 @@ class MyBaseViewUsingEnhancedRequest(RequestMixin, View):
parser_classes = parsers.DEFAULT_PARSERS
def dispatch(self, request, *args, **kwargs):
- request = self.prepare_request(request)
+ self.request = request = self.create_request(request)
return super(MyBaseViewUsingEnhancedRequest, self).dispatch(request, *args, **kwargs)
diff --git a/examples/views.py b/examples/views.py
index 606edc3a..e7ef2ec9 100644
--- a/examples/views.py
+++ b/examples/views.py
@@ -2,7 +2,7 @@ from djangorestframework.views import View
from djangorestframework.response import Response
-class MockView(View):
+class ProxyView(View):
"""
A view that just acts as a proxy to call non-djangorestframework views, while still
displaying the browsable API interface.
@@ -11,10 +11,10 @@ class MockView(View):
view_class = None
def dispatch(self, request, *args, **kwargs):
- request = self.prepare_request(request)
+ self.request = request = self.create_request(request)
if request.method in ['PUT', 'POST']:
self.response = self.view_class.as_view()(request, *args, **kwargs)
- return super(MockView, self).dispatch(request, *args, **kwargs)
+ return super(ProxyView, self).dispatch(request, *args, **kwargs)
def get(self, request, *args, **kwargs):
return Response()
@@ -31,4 +31,4 @@ class MockView(View):
elif name == '__doc__':
return self.view_class.__doc__
else:
- return super(MockView, self).__getattribute__(name)
+ return super(ProxyView, self).__getattribute__(name)