Skip to content

Commit

Permalink
Merge pull request #2518 from longhotsummer/patch-1
Browse files Browse the repository at this point in the history
FIX: Don't default to list in method args
  • Loading branch information
tomchristie committed Feb 4, 2015
2 parents d21617f + e13d2af commit 3b00824
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions rest_framework/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ def api_view(http_method_names=None):
Decorator that converts a function-based view into an APIView subclass.
Takes a list of allowed methods for the view as an argument.
"""
if http_method_names is None:
http_method_names = ['GET']
http_method_names = ['GET'] if (http_method_names is None) else http_method_names

def decorator(func):

Expand Down Expand Up @@ -109,10 +108,12 @@ def decorator(func):
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.
"""
methods = ['get'] if (methods is None) else methods

def decorator(func):
func.bind_to_methods = methods
func.detail = True
Expand All @@ -121,10 +122,12 @@ def decorator(func):
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.
"""
methods = ['get'] if (methods is None) else methods

def decorator(func):
func.bind_to_methods = methods
func.detail = False
Expand Down

0 comments on commit 3b00824

Please sign in to comment.