Created
August 24, 2012 04:26
-
-
Save callmephilip/3445408 to your computer and use it in GitHub Desktop.
[Python Django] view decorator with parameters
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 functools import wraps | |
from django.utils.decorators import available_attrs | |
def my_decorator(parameter_name): | |
def decorator(view_func): | |
@wraps(view_func, assigned=available_attrs(view_func)) | |
def _wrapped_view(request, *args, **kwargs): | |
return view_func(request, *args, **kwargs) | |
return _wrapped_view | |
return decorator |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment