Skip to content

Commit 7bb5fd2

Browse files
committed
FIX: Don't default to list in method args
Fixes @list_route and @detail_route so that they don't initialize their `methods` parameter as a list. In some cases the list gets cleared, and the result is that default parameter is now empty, and may get reused unexpectedly.
1 parent 4618134 commit 7bb5fd2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

rest_framework/decorators.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,12 @@ def decorator(func):
109109
return decorator
110110

111111

112-
def detail_route(methods=['get'], **kwargs):
112+
def detail_route(methods=None, **kwargs):
113113
"""
114114
Used to mark a method on a ViewSet that should be routed for detail requests.
115115
"""
116+
if methods is None:
117+
methods = ['get']
116118
def decorator(func):
117119
func.bind_to_methods = methods
118120
func.detail = True
@@ -121,10 +123,12 @@ def decorator(func):
121123
return decorator
122124

123125

124-
def list_route(methods=['get'], **kwargs):
126+
def list_route(methods=None, **kwargs):
125127
"""
126128
Used to mark a method on a ViewSet that should be routed for list requests.
127129
"""
130+
if methods is None:
131+
methods = ['get']
128132
def decorator(func):
129133
func.bind_to_methods = methods
130134
func.detail = False

0 commit comments

Comments
 (0)