utils.encoding.escape_uri_path()

escape_uri_path(path) [source] Escapes the unsafe characters from the path portion of a Uniform Resource Identifier (URI).

utils.deprecation.MiddlewareMixin

class django.utils.deprecation.MiddlewareMixin Django provides django.utils.deprecation.MiddlewareMixin to ease creating middleware classes that are compatible with both MIDDLEWARE and the old MIDDLEWARE_CLASSES. All middleware classes included with Django are compatible with both settings. The mixin provides an __init__() method that accepts an optional get_response argument and stores it in self.get_response. The __call__() method: Calls self.process_request(request) (if defined). Calls se

utils.decorators.method_decorator()

method_decorator(decorator, name='') [source] Converts a function decorator into a method decorator. It can be used to decorate methods or classes; in the latter case, name is the name of the method to be decorated and is required. decorator may also be a list or tuple of functions. They are wrapped in reverse order so that the call order is the order in which the functions appear in the list/tuple. See decorating class based views for example usage. Changed in Django 1.9: The ability to de

utils.decorators.decorator_from_middleware_with_args()

decorator_from_middleware_with_args(middleware_class) [source] Like decorator_from_middleware, but returns a function that accepts the arguments to be passed to the middleware_class. For example, the cache_page() decorator is created from the CacheMiddleware like this: cache_page = decorator_from_middleware_with_args(CacheMiddleware) @cache_page(3600) def my_view(request): pass

utils.decorators.decorator_from_middleware()

decorator_from_middleware(middleware_class) [source] Given a middleware class, returns a view decorator. This lets you use middleware functionality on a per-view basis. The middleware is created with no params passed. It assumes middleware that’s compatible with the old style of Django 1.9 and earlier (having methods like process_request(), process_exception(), and process_response()).

utils.dateparse.parse_time()

parse_time(value) [source] Parses a string and returns a datetime.time. UTC offsets aren’t supported; if value describes one, the result is None.

utils.dateparse.parse_duration()

parse_duration(value) [source] Parses a string and returns a datetime.timedelta. Expects data in the format "DD HH:MM:SS.uuuuuu" or as specified by ISO 8601 (e.g. P4DT1H15M20S which is equivalent to 4 1:15:20).

utils.dateparse.parse_datetime()

parse_datetime(value) [source] Parses a string and returns a datetime.datetime. UTC offsets are supported; if value describes one, the result’s tzinfo attribute is a FixedOffset instance.

utils.dateparse.parse_date()

parse_date(value) [source] Parses a string and returns a datetime.date.

utils.cache.patch_vary_headers()

patch_vary_headers(response, newheaders) [source] Adds (or updates) the Vary header in the given HttpResponse object. newheaders is a list of header names that should be in Vary. Existing headers in Vary aren’t removed.