Skip to content

Instantly share code, notes, and snippets.

@tclancy
Created January 30, 2013 15:37
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 tclancy/4674070 to your computer and use it in GitHub Desktop.
Save tclancy/4674070 to your computer and use it in GitHub Desktop.
def my_decorator(function=None):
def _decorator(view_function):
def _view(request, *args, **kwargs):
if not some_security_check(request.user):
return HttpResponseRedirect(reverse('auth_login'))
return view_function(request, *args, **kwargs)
_view.__name__ = view_function.__name__
_view.__dict__ = view_function.__dict__
_view.__doc__ = view_function.__doc__
_view.__module__ = view_function.__module__
return _view
if function is None:
return _decorator
else:
return _decorator(function)
@tclancy
Copy link
Author

tclancy commented Jan 30, 2013

Ensures the proper info gets passed from the view so admindocs displays your view instead of a 404 of the decorator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment