Forked from Akash1362000/class_based_middleware.py
Last active
August 11, 2021 18:18
-
-
Save imgVOID/2f4cc375d3d50b1908f927bc08b2c4c4 to your computer and use it in GitHub Desktop.
Пользовательский Django Middleware на основе класса
This file contains hidden or 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
class ExampleMiddleware: | |
def _init_(self, get_response): | |
self.get_response = get_response | |
def _call_(self, request): | |
# Код, вызываемый перед представлением при каждом запросе. | |
response = self.get_response(request) | |
# Код, вызываемый после представления при каждом запросе. | |
return response | |
def process_view(request, view_func, view_args, view_kwargs): | |
# Код, вызываемый непосредственно перед кодом представления. | |
def process_exception(request, exception): | |
# Код, вызываемый при выбросе исключения. | |
def process_template_response(request, response): | |
# Код, вызываемый при наличии в запросе метода render(). | |
return response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment