mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-02 20:54:42 +03:00
Use inline if
This commit is contained in:
parent
7bb5fd270d
commit
d920683237
|
@ -18,8 +18,7 @@ def api_view(http_method_names=None):
|
||||||
Decorator that converts a function-based view into an APIView subclass.
|
Decorator that converts a function-based view into an APIView subclass.
|
||||||
Takes a list of allowed methods for the view as an argument.
|
Takes a list of allowed methods for the view as an argument.
|
||||||
"""
|
"""
|
||||||
if http_method_names is None:
|
http_method_names = ['GET'] if http_method_names is None else http_method_names
|
||||||
http_method_names = ['GET']
|
|
||||||
|
|
||||||
def decorator(func):
|
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.
|
Used to mark a method on a ViewSet that should be routed for detail requests.
|
||||||
"""
|
"""
|
||||||
if methods is None:
|
methods = ['get'] if methods is None else methods
|
||||||
methods = ['get']
|
|
||||||
def decorator(func):
|
def decorator(func):
|
||||||
func.bind_to_methods = methods
|
func.bind_to_methods = methods
|
||||||
func.detail = True
|
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.
|
Used to mark a method on a ViewSet that should be routed for list requests.
|
||||||
"""
|
"""
|
||||||
if methods is None:
|
methods = ['get'] if methods is None else methods
|
||||||
methods = ['get']
|
|
||||||
def decorator(func):
|
def decorator(func):
|
||||||
func.bind_to_methods = methods
|
func.bind_to_methods = methods
|
||||||
func.detail = False
|
func.detail = False
|
||||||
|
|
Loading…
Reference in New Issue
Block a user