Skip to content

Instantly share code, notes, and snippets.

@callmephilip
Created August 24, 2012 04:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save callmephilip/3445408 to your computer and use it in GitHub Desktop.
Save callmephilip/3445408 to your computer and use it in GitHub Desktop.
[Python Django] view decorator with parameters
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