mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-07 13:54:47 +03:00
Merge 051bee14bf
into d540f0262b
This commit is contained in:
commit
04bb70c8ea
|
@ -15,7 +15,7 @@ from django.utils import six
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
|
|
||||||
|
|
||||||
def api_view(http_method_names=None):
|
def api_view(http_method_names=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
Decorator that converts a function-based view into an APIView subclass.
|
Decorator that converts a function-based view into an APIView subclass.
|
||||||
Takes a list of allowed methods for the view as an argument.
|
Takes a list of allowed methods for the view as an argument.
|
||||||
|
@ -71,6 +71,10 @@ def api_view(http_method_names=None):
|
||||||
WrappedAPIView.permission_classes = getattr(func, 'permission_classes',
|
WrappedAPIView.permission_classes = getattr(func, 'permission_classes',
|
||||||
APIView.permission_classes)
|
APIView.permission_classes)
|
||||||
|
|
||||||
|
# Extend APIView with attrs mentioned explicitly
|
||||||
|
for (attrname, attrvalue) in kwargs.items():
|
||||||
|
setattr(WrappedAPIView, attrname, attrvalue)
|
||||||
|
|
||||||
return WrappedAPIView.as_view()
|
return WrappedAPIView.as_view()
|
||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user