django-rest-framework/examples/mixin/urls.py

26 lines
1001 B
Python
Raw Normal View History

2011-12-29 17:31:12 +04:00
from djangorestframework.compat import View # Use Django 1.3's django.views.generic.View, or fall back to a clone of that if Django < 1.3
from djangorestframework.mixins import ResponseMixin
2011-04-28 22:54:30 +04:00
from djangorestframework.renderers import DEFAULT_RENDERERS
from djangorestframework.response import Response
2012-02-22 00:57:36 +04:00
from djangorestframework.reverse import reverse
from django.conf.urls.defaults import patterns, url
class ExampleView(ResponseMixin, View):
"""An example view using Django 1.3's class based views.
2011-04-28 22:54:30 +04:00
Uses djangorestframework's RendererMixin to provide support for multiple output formats."""
renderer_classes = DEFAULT_RENDERERS
def get(self, request):
response = Response({'description': 'Some example content',
2012-02-22 00:12:14 +04:00
'url': reverse('mixin-view', request)}, status=200)
2012-02-10 13:05:20 +04:00
self.response = self.prepare_response(response)
return self.response
urlpatterns = patterns('',
url(r'^$', ExampleView.as_view(), name='mixin-view'),
)