Skip to content

Commit 3b00824

Browse files
committed
Merge pull request #2518 from longhotsummer/patch-1
FIX: Don't default to list in method args
2 parents d21617f + e13d2af commit 3b00824

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

rest_framework/decorators.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ def api_view(http_method_names=None):
1818
Decorator that converts a function-based view into an APIView subclass.
1919
Takes a list of allowed methods for the view as an argument.
2020
"""
21-
if http_method_names is None:
22-
http_method_names = ['GET']
21+
http_method_names = ['GET'] if (http_method_names is None) else http_method_names
2322

2423
def decorator(func):
2524

@@ -109,10 +108,12 @@ def decorator(func):
109108
return decorator
110109

111110

112-
def detail_route(methods=['get'], **kwargs):
111+
def detail_route(methods=None, **kwargs):
113112
"""
114113
Used to mark a method on a ViewSet that should be routed for detail requests.
115114
"""
115+
methods = ['get'] if (methods is None) else methods
116+
116117
def decorator(func):
117118
func.bind_to_methods = methods
118119
func.detail = True
@@ -121,10 +122,12 @@ def decorator(func):
121122
return decorator
122123

123124

124-
def list_route(methods=['get'], **kwargs):
125+
def list_route(methods=None, **kwargs):
125126
"""
126127
Used to mark a method on a ViewSet that should be routed for list requests.
127128
"""
129+
methods = ['get'] if (methods is None) else methods
130+
128131
def decorator(func):
129132
func.bind_to_methods = methods
130133
func.detail = False

0 commit comments

Comments
 (0)