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
|
2011-04-27 21:07:28 +04:00
|
|
|
from djangorestframework.mixins import ResponseMixin
|
2011-04-28 22:54:30 +04:00
|
|
|
from djangorestframework.renderers import DEFAULT_RENDERERS
|
2011-02-19 13:26:27 +03:00
|
|
|
from djangorestframework.response import Response
|
2012-02-22 00:47:55 +04:00
|
|
|
from djangorestframework.reverse import reverse
|
2011-02-19 13:26:27 +03:00
|
|
|
|
|
|
|
from django.conf.urls.defaults import patterns, url
|
|
|
|
|
|
|
|
|
2011-04-27 21:07:28 +04:00
|
|
|
class ExampleView(ResponseMixin, View):
|
2011-02-19 13:26:27 +03:00
|
|
|
"""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."""
|
|
|
|
renderers = DEFAULT_RENDERERS
|
2011-02-19 13:26:27 +03:00
|
|
|
|
|
|
|
def get(self, request):
|
|
|
|
response = Response(200, {'description': 'Some example content',
|
2012-02-20 14:28:50 +04:00
|
|
|
'url': reverse('mixin-view', request)})
|
2011-05-02 22:49:12 +04:00
|
|
|
return self.render(response)
|
2011-02-19 13:26:27 +03:00
|
|
|
|
|
|
|
|
|
|
|
urlpatterns = patterns('',
|
|
|
|
url(r'^$', ExampleView.as_view(), name='mixin-view'),
|
|
|
|
)
|
|
|
|
|