diff options
| author | Greg Kempe | 2015-02-04 16:03:03 +0200 | 
|---|---|---|
| committer | Greg Kempe | 2015-02-04 16:03:03 +0200 | 
| commit | 7bb5fd270da98d8957efb4bf0e4bd4679ddbcf5f (patch) | |
| tree | 1f74161bcd546509f1a0360b9d6f8ea7700ff53d /rest_framework | |
| parent | 46181341d5579cb7a1b07cd7203b2f94b6c9c119 (diff) | |
| download | django-rest-framework-7bb5fd270da98d8957efb4bf0e4bd4679ddbcf5f.tar.bz2 | |
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.
Diffstat (limited to 'rest_framework')
| -rw-r--r-- | rest_framework/decorators.py | 8 | 
1 files changed, 6 insertions, 2 deletions
| diff --git a/rest_framework/decorators.py b/rest_framework/decorators.py index 325435b3..a68227c1 100644 --- a/rest_framework/decorators.py +++ b/rest_framework/decorators.py @@ -109,10 +109,12 @@ def permission_classes(permission_classes):      return decorator -def detail_route(methods=['get'], **kwargs): +def detail_route(methods=None, **kwargs):      """      Used to mark a method on a ViewSet that should be routed for detail requests.      """ +    if methods is None: +        methods = ['get']      def decorator(func):          func.bind_to_methods = methods          func.detail = True @@ -121,10 +123,12 @@ def detail_route(methods=['get'], **kwargs):      return decorator -def list_route(methods=['get'], **kwargs): +def list_route(methods=None, **kwargs):      """      Used to mark a method on a ViewSet that should be routed for list requests.      """ +    if methods is None: +        methods = ['get']      def decorator(func):          func.bind_to_methods = methods          func.detail = False | 
