django-rest-framework/examples/mixin/urls.py
Daniel Izquierdo 8bc2fc54c5 Update examples to use the new custom `reverse()'
This fixes #167 except for the docs
2012-02-20 19:28:50 +09:00

26 lines
999 B
Python

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
from djangorestframework.renderers import DEFAULT_RENDERERS
from djangorestframework.response import Response
from djangorestframework.utils 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.
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', request)}, status=200)
self.response = self.prepare_response(response)
return self.response
urlpatterns = patterns('',
url(r'^$', ExampleView.as_view(), name='mixin-view'),
)