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

25 lines
951 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
from django.conf.urls.defaults import patterns, url
from django.core.urlresolvers import reverse
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',
'url': reverse('mixin-view')}, status=200)
return self.prepare_response(response)
urlpatterns = patterns('',
url(r'^$', ExampleView.as_view(), name='mixin-view'),
)