mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-06 21:40:13 +03:00
Allow api_view setup attrs mentioned explicitly
This commit is contained in:
parent
d540f0262b
commit
051bee14bf
|
@ -15,7 +15,7 @@ from django.utils import six
|
|||
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.
|
||||
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',
|
||||
APIView.permission_classes)
|
||||
|
||||
# Extend APIView with attrs mentioned explicitly
|
||||
for (attrname, attrvalue) in kwargs.items():
|
||||
setattr(WrappedAPIView, attrname, attrvalue)
|
||||
|
||||
return WrappedAPIView.as_view()
|
||||
return decorator
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user