tomchristie/django-rest-framework — pull request #261 by j4mie (2012-09-14 15:19:46+00:00)
Title: First stab at new function-based view decorators

First stab at improved decorators for function-based views, for discussion.

Basic idea:

```python
@api_view(['GET', 'POST'])
@renderer_classes([JSONRenderer])
def my_view(request): # request is now a DRF Request!
# view logic here
return Response({'data': 'woohoo'})
```

The order of the stacked decorators doesn't matter.

Throttling and permissions don't seem to work just yet (I can't make the tests pass, haven't investigated much more).

One thought for now: I think the `api_view` decorator taking a list of HTTP methods might be a bit odd. What do you think about:

```python
@api_view
@allowed_methods(['GET', 'POST'])
@renderer_classes([JSONRenderer])
def my_view(request):
# etc...
```

Strictly, `api_view` wouldn't be necessary at all in this case (using any of the decorators is enough to wrap up your function) but it would make the very simplest case (a function that responds to any HTTP method) really neat:

```python
@api_view
def my_view(request):
return Response({'data': 'woohoo'})
```