Module decorators
Functions that help with dynamically creating decorators for views.
source linkClasses
Functions
▶ def decorator_from_middleware(middleware_class) Given a middleware class (not an instance), return a view decorator. This lets you use middleware functionality on a per-view basis. The middleware is created with no params passed.
▶ def decorator_from_middleware_with_args(middleware_class) Like decorator_from_middleware, but return a function that accepts the arguments to be passed to the middleware_class. Use like::
cache_page = decorator_from_middleware_with_args(CacheMiddleware)
# ...
@cache_page(3600)
def my_view(request):
# ...
Reexports
▶ def method_decorator(decorator, name='') Convert a function decorator into a method decorator
▷ def sync_and_async_middleware(func) Mark a middleware factory as returning a hybrid middleware supporting both types of request.
▷ def sync_only_middleware(func) Mark a middleware factory as returning a sync middleware. This is the default.