diff options
| author | Greg Kempe | 2015-02-04 16:13:30 +0200 |
|---|---|---|
| committer | Greg Kempe | 2015-02-04 16:13:30 +0200 |
| commit | d920683237bd2eb17d110a80fc09708a67340f01 (patch) | |
| tree | 2573922e023966f11b26e162317b694a27d986c6 | |
| parent | 7bb5fd270da98d8957efb4bf0e4bd4679ddbcf5f (diff) | |
| download | django-rest-framework-d920683237bd2eb17d110a80fc09708a67340f01.tar.bz2 | |
Use inline if
| -rw-r--r-- | rest_framework/decorators.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/rest_framework/decorators.py b/rest_framework/decorators.py index a68227c1..7604eae1 100644 --- a/rest_framework/decorators.py +++ b/rest_framework/decorators.py @@ -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): @@ -113,8 +112,8 @@ 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'] + methods = ['get'] if methods is None else methods + def decorator(func): func.bind_to_methods = methods func.detail = True @@ -127,8 +126,8 @@ 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'] + methods = ['get'] if methods is None else methods + def decorator(func): func.bind_to_methods = methods func.detail = False |
