Last active
August 25, 2016 17:06
-
-
Save froi/1037fd1b50a7a44d61eee9b4dc0151e7 to your computer and use it in GitHub Desktop.
Decorator for DRF to mark a view function as excluded from a list of api versions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework.exceptions import NotFound | |
def not_available_api_version(excluded_api_versions=None): | |
def decorator(func): | |
@wraps(func) | |
def wrapper(x, request, *args, **kwargs): | |
if excluded_api_versions and request.version in excluded_api_versions: | |
raise NotFound(detail=None) | |
return func(x,request, *args, **kwargs) | |
return wrapper | |
return decorator |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment