add: Страницы обработки ошибок
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 42s
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 42s
This commit is contained in:
@@ -45,6 +45,12 @@ services:
|
||||
cp /nginx_configs_host/nginx/oknardia-app--external-nginx.conf.example /nginx_configs_host/nginx/oknardia-app--external-nginx.conf;
|
||||
echo 'INIT: Created new nginx config with correct paths';
|
||||
fi &&
|
||||
ERROR_DIR=/home/app/web/public/media/_error &&
|
||||
mkdir -p "$$ERROR_DIR" &&
|
||||
for code in 400 401 403 404 413 429 500 502 503 504; do
|
||||
cp /home/user/path-to-oknardia-app/oknardia/templates/error/$${code}.html "$$ERROR_DIR/$${code}.html";
|
||||
done &&
|
||||
cp /home/user/path-to-oknardia-app/oknardia/templates/error/under_reconstruction.html "$$ERROR_DIR/under_reconstruction.html"
|
||||
python -m gunicorn --workers 2 --bind 0.0.0.0:8000 --timeout 120 oknardia.wsgi:application"
|
||||
|
||||
# Пробрасывание портов
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""oknardia Конфигурация URL"""
|
||||
from django.contrib import admin
|
||||
from django.urls import include, path, re_path
|
||||
from django.conf.urls.static import static
|
||||
from django.urls import include, re_path, path
|
||||
from django.http import FileResponse
|
||||
from pathlib import Path
|
||||
import environ
|
||||
import mimetypes
|
||||
import os
|
||||
|
||||
# Инициализируем env
|
||||
env = environ.Env()
|
||||
@@ -174,10 +174,13 @@ PUBLIC_ROOT_URLPATTERNS = [
|
||||
# (чтобы отдавать файлы быстро и не проверять остальные рулы)
|
||||
urlpatterns = [*PUBLIC_ROOT_URLPATTERNS, *urlpatterns]
|
||||
|
||||
handler404 = 'web.views.handler404'
|
||||
handler400 = 'web.views.handler400'
|
||||
handler403 = 'web.views.handler403'
|
||||
handler500 = 'web.views.handler500'
|
||||
|
||||
# Для локального тестирования production конфига: отдача медиа через Django
|
||||
# В реальном production медиа обслуживает Nginx!
|
||||
import os
|
||||
if DEBUG or env.bool('ALLOW_MEDIA_SERVE', default=False):
|
||||
from django.views.static import serve as serve_static
|
||||
# Проверяем что директория медиа существует
|
||||
@@ -196,6 +199,13 @@ if DEBUG or env.bool('ALLOW_MEDIA_SERVE', default=False):
|
||||
if DEBUG:
|
||||
# --- страничка для тестирования верстки текста в блоге
|
||||
urlpatterns += [re_path(r'^blog/tmp[/*]$', service.tmp),]
|
||||
# --- странички для тестирования страниц с кодами ошибок
|
||||
urlpatterns += [
|
||||
re_path(r'^400$', views.handler400),
|
||||
re_path(r'^403$', views.handler403),
|
||||
re_path(r'^404$', views.handler404),
|
||||
re_path(r'^500$', views.handler500),
|
||||
]
|
||||
# ___ ____ _ _____ _ _ _____ _
|
||||
# | | | | \ ___| |_ _ _ ___ |_ _|___ ___| | |_ ___ ___ | _ |___ ___ ___| |
|
||||
# |_ | | | | -_| . | | | . | | | | . | . | | . | .'| _| | __| .'| | -_| |
|
||||
|
||||
31
oknardia/templates/error/400.html
Normal file
31
oknardia/templates/error/400.html
Normal file
@@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>400 — Некорректный запрос</title>
|
||||
<!-- Аналитика: Google Analytics 4, Yandex.Metrika, Top.Mail.Ru -->
|
||||
<script src="/static/js/analytics.js" type="text/javascript"></script>
|
||||
<style>
|
||||
.container::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0; left: 0; right: 0; bottom: 0;
|
||||
background-image: url('/media/img_seria/1LG-504D12_2.jpg');
|
||||
opacity: 0.6; /* Полупрозрачность только для картинки */
|
||||
z-index: -1; /* Уводит картинку под текст */
|
||||
background-position: 18% 15%;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 200px auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" style="margin: 10% 0 0 20%;">
|
||||
<h1 style="font-size: 120px; margin: 0; color: #ccc; background-image: url('/static/img/oknardia_logo.gif'); background-position: left 65%; background-repeat: no-repeat; background-size: 400px auto;"><i style="padding-left: 420px">400</i></h1>
|
||||
<h2 style="color: #333; font-size: 40px;">Некорректный запрос</h2>
|
||||
<h4 style="color: #666; margin: 0 0 0 30px; font-size: 20px;">Сервер не может обработать ваш запрос. Пожалуйста, проверьте корректность данных.</h4>
|
||||
<p style="margin-top: 55px;"><a href="/">Вернуться на главную oknardia.ru</a></p>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
29
oknardia/templates/error/401.html
Normal file
29
oknardia/templates/error/401.html
Normal file
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>401 — Требуется авторизация</title>
|
||||
<style>
|
||||
.container::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0; left: 0; right: 0; bottom: 0;
|
||||
background-image: url('/media/img_seria/1LG-504D12_2.jpg');
|
||||
opacity: 0.6;
|
||||
z-index: -1;
|
||||
background-position: 18% 15%;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 200px auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" style="margin: 10% 0 0 20%;">
|
||||
<h1 style="font-size: 120px; margin: 0; color: #ccc; background-image: url('/media/img_seria/1LG-504D12_2.jpg'); background-position: left 65%; background-repeat: no-repeat; background-size: 400px auto;"><i style="padding-left: 420px">401</i></h1>
|
||||
<h2 style="color: #333; font-size: 40px;">Требуется авторизация</h2>
|
||||
<h4 style="color: #666; margin: 0 0 0 30px; font-size: 20px;">Для доступа к этому ресурсу требуется авторизация.</h4>
|
||||
<p style="margin-top: 55px;"><a href="/login-logout">Войти в систему</a> или <a href="/">вернуться на главную</a></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
32
oknardia/templates/error/403.html
Normal file
32
oknardia/templates/error/403.html
Normal file
@@ -0,0 +1,32 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>403 — Доступ запрещён</title>
|
||||
<!-- Аналитика: Google Analytics 4, Yandex.Metrika, Top.Mail.Ru -->
|
||||
<script src="/static/js/analytics.js" type="text/javascript"></script>
|
||||
<style>
|
||||
.container::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0; left: 0; right: 0; bottom: 0;
|
||||
background-image: url('/media/img_seria/1LG-504D12_2.jpg');
|
||||
opacity: 0.6; /* Полупрозрачность только для картинки */
|
||||
z-index: -1; /* Уводит картинку под текст */
|
||||
background-position: 18% 15%;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 200px auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" style="margin: 10% 0 0 20%;">
|
||||
<h1 style="font-size: 120px; margin: 0; color: #ccc; background-image: url('/static/img/oknardia_logo.gif'); background-position: left 65%; background-repeat: no-repeat; background-size: 400px auto;"><i style="padding-left: 420px">403</i></h1>
|
||||
<h2 style="color: #333; font-size: 40px;">Доступ запрещён</h2>
|
||||
<h4 style="color: #666; margin: 0 0 0 30px; font-size: 20px;">У вас нет прав для доступа к этому ресурсу. Если вы считаете это ошибкой, свяжитесь с администратором.</h4>
|
||||
<p style="margin-top: 55px;"><a href="/">Вернуться на главную oknardia.ru</a></p>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
31
oknardia/templates/error/404.html
Normal file
31
oknardia/templates/error/404.html
Normal file
@@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>404 — Страница не найдена</title>
|
||||
<!-- Аналитика: Google Analytics 4, Yandex.Metrika, Top.Mail.Ru -->
|
||||
<script src="/static/js/analytics.js" type="text/javascript"></script>
|
||||
<style>
|
||||
.container::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0; left: 0; right: 0; bottom: 0;
|
||||
background-image: url('/media/img_seria/1LG-504D12_2.jpg');
|
||||
opacity: 0.6; /* Полупрозрачность только для картинки */
|
||||
z-index: -1; /* Уводит картинку под текст */
|
||||
background-position: 18% 15%;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 200px auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" style="margin: 10% 0 0 20%;">
|
||||
<h1 style="font-size: 120px; margin: 0; color: #ccc; background-image: url('/static/img/oknardia_logo.gif'); background-position: left 65%; background-repeat: no-repeat; background-size: 400px auto;"><i style="padding-left: 420px">404</i></h1>
|
||||
<h2 style="color: #333; font-size: 40px;">Страница не найдена</h2>
|
||||
<h4 style="color: #666; margin: 0 0 0 30px; font-size: 20px;">К сожалению, запрашиваемая страница не существует или была удалена.</h4>
|
||||
<p style="margin-top: 55px;"><a href="/">Вернуться на главную oknardia.ru</a></p>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
29
oknardia/templates/error/413.html
Normal file
29
oknardia/templates/error/413.html
Normal file
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>413 — Файл слишком большой</title>
|
||||
<style>
|
||||
.container::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0; left: 0; right: 0; bottom: 0;
|
||||
background-image: url('/media/img_seria/1LG-504D12_2.jpg');
|
||||
opacity: 0.6;
|
||||
z-index: -1;
|
||||
background-position: 18% 15%;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 200px auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" style="margin: 10% 0 0 20%;">
|
||||
<h1 style="font-size: 120px; margin: 0; color: #ccc; background-image: url('/media/img_seria/1LG-504D12_2.jpg'); background-position: left 65%; background-repeat: no-repeat; background-size: 400px auto;"><i style="padding-left: 420px">413</i></h1>
|
||||
<h2 style="color: #333; font-size: 40px;">Файл слишком большой</h2>
|
||||
<h4 style="color: #666; margin: 0 0 0 30px; font-size: 20px;">Размер загружаемого файла превышает допустимый лимит (максимум 10 МБ).</h4>
|
||||
<p style="margin-top: 55px;"><a href="/">Вернуться на главную oknardia.ru</a></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
29
oknardia/templates/error/429.html
Normal file
29
oknardia/templates/error/429.html
Normal file
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>429 — Слишком много запросов</title>
|
||||
<style>
|
||||
.container::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0; left: 0; right: 0; bottom: 0;
|
||||
background-image: url('/media/img_seria/1LG-504D12_2.jpg');
|
||||
opacity: 0.6;
|
||||
z-index: -1;
|
||||
background-position: 18% 15%;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 200px auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" style="margin: 10% 0 0 20%;">
|
||||
<h1 style="font-size: 120px; margin: 0; color: #ccc; background-image: url('/media/img_seria/1LG-504D12_2.jpg'); background-position: left 65%; background-repeat: no-repeat; background-size: 400px auto;"><i style="padding-left: 420px">429</i></h1>
|
||||
<h2 style="color: #333; font-size: 40px;">Слишком много запросов</h2>
|
||||
<h4 style="color: #666; margin: 0 0 0 30px; font-size: 20px;">Вы отправляете слишком много запросов. Пожалуйста, немного подождите и попробуйте снова.</h4>
|
||||
<p style="margin-top: 55px;"><a href="/">Вернуться на главную oknardia.ru</a></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
31
oknardia/templates/error/500.html
Normal file
31
oknardia/templates/error/500.html
Normal file
@@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>500 — Внутренняя ошибка сервера</title>
|
||||
<!-- Аналитика: Google Analytics 4, Yandex.Metrika, Top.Mail.Ru -->
|
||||
<script src="/static/js/analytics.js" type="text/javascript"></script>
|
||||
<style>
|
||||
.container::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0; left: 0; right: 0; bottom: 0;
|
||||
background-image: url('/media/img_seria/1LG-504D12_2.jpg');
|
||||
opacity: 0.6; /* Полупрозрачность только для картинки */
|
||||
z-index: -1; /* Уводит картинку под текст */
|
||||
background-position: 18% 15%;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 200px auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" style="margin: 10% 0 0 20%;">
|
||||
<h1 style="font-size: 120px; margin: 0; color: #ccc; background-image: url('/media/img_seria/1LG-504D12_2.jpg'); background-position: left 65%; background-repeat: no-repeat; background-size: 400px auto;"><i style="padding-left: 420px">500</i></h1>
|
||||
<h2 style="color: #333; font-size: 40px;">Внутренняя ошибка сервера</h2>
|
||||
<h4 style="color: #666; margin: 0 0 0 30px; font-size: 20px;">На нашем сервере произошла непредвиденная ошибка. Команда разработчиков уже работает над решением проблемы.</h4>
|
||||
<p style="color: #999; margin: 20px 0 0 30px; font-size: 14px;">Если проблема сохраняется, пожалуйста, свяжитесь с администратором: <a href="mailto:info@oknardia.ru">info@oknardia.ru</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
29
oknardia/templates/error/502.html
Normal file
29
oknardia/templates/error/502.html
Normal file
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>502 — Плохой шлюз</title>
|
||||
<style>
|
||||
.container::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0; left: 0; right: 0; bottom: 0;
|
||||
background-image: url('/media/img_seria/1LG-504D12_2.jpg');
|
||||
opacity: 0.6;
|
||||
z-index: -1;
|
||||
background-position: 18% 15%;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 200px auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" style="margin: 10% 0 0 20%;">
|
||||
<h1 style="font-size: 120px; margin: 0; color: #ccc; background-image: url('/media/img_seria/1LG-504D12_2.jpg'); background-position: left 65%; background-repeat: no-repeat; background-size: 400px auto;"><i style="padding-left: 420px">502</i></h1>
|
||||
<h2 style="color: #333; font-size: 40px;">Плохой шлюз</h2>
|
||||
<h4 style="color: #666; margin: 0 0 0 30px; font-size: 20px;">Сервер приложения временно недоступен. Мы работаем над восстановлением работоспособности.</h4>
|
||||
<p style="color: #999; margin: 20px 0 0 30px; font-size: 14px;">Пожалуйста, попробуйте перезагрузить страницу через несколько минут. Если проблема сохраняется, свяжитесь с нами: <a href="mailto:info@oknardia.ru">info@oknardia.ru</a></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
29
oknardia/templates/error/503.html
Normal file
29
oknardia/templates/error/503.html
Normal file
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>503 — Сервис недоступен</title>
|
||||
<style>
|
||||
.container::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0; left: 0; right: 0; bottom: 0;
|
||||
background-image: url('/media/img_seria/1LG-504D12_2.jpg');
|
||||
opacity: 0.6;
|
||||
z-index: -1;
|
||||
background-position: 18% 15%;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 200px auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" style="margin: 10% 0 0 20%;">
|
||||
<h1 style="font-size: 120px; margin: 0; color: #ccc; background-image: url('/media/img_seria/1LG-504D12_2.jpg'); background-position: left 65%; background-repeat: no-repeat; background-size: 400px auto;"><i style="padding-left: 420px">503</i></h1>
|
||||
<h2 style="color: #333; font-size: 40px;">Сервис недоступен</h2>
|
||||
<h4 style="color: #666; margin: 0 0 0 30px; font-size: 20px;">Сайт временно недоступен для плановых работ. Мы скоро вернёмся!</h4>
|
||||
<p style="color: #999; margin: 20px 0 0 30px; font-size: 14px;">Информация об обслуживании обновляется автоматически. Спасибо за терпение!</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
29
oknardia/templates/error/504.html
Normal file
29
oknardia/templates/error/504.html
Normal file
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>504 — Тайм-аут шлюза</title>
|
||||
<style>
|
||||
.container::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0; left: 0; right: 0; bottom: 0;
|
||||
background-image: url('/media/img_seria/1LG-504D12_2.jpg');
|
||||
opacity: 0.6;
|
||||
z-index: -1;
|
||||
background-position: 18% 15%;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 200px auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" style="margin: 10% 0 0 20%;">
|
||||
<h1 style="font-size: 120px; margin: 0; color: #ccc; background-image: url('/media/img_seria/1LG-504D12_2.jpg'); background-position: left 65%; background-repeat: no-repeat; background-size: 400px auto;"><i style="padding-left: 420px">504</i></h1>
|
||||
<h2 style="color: #333; font-size: 40px;">Тайм-аут шлюза</h2>
|
||||
<h4 style="color: #666; margin: 0 0 0 30px; font-size: 20px;">Сервер приложения слишком долго отвечает на запрос. Это может быть перегрузка или технический сбой.</h4>
|
||||
<p style="color: #999; margin: 20px 0 0 30px; font-size: 14px;">Попробуйте перезагрузить страницу через несколько минут. Если проблема повторится, свяжитесь с поддержкой: <a href="mailto:info@oknardia.ru">info@oknardia.ru</a></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
29
oknardia/templates/error/under_reconstruction.html
Normal file
29
oknardia/templates/error/under_reconstruction.html
Normal file
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Технические работы</title>
|
||||
<style>
|
||||
.container::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0; left: 0; right: 0; bottom: 0;
|
||||
background-image: url('/media/img_seria/1LG-504D12_2.jpg');
|
||||
opacity: 0.6;
|
||||
z-index: -1;
|
||||
background-position: 18% 15%;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 200px auto;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" style="margin: 10% 0 0 20%;">
|
||||
<h1 style="font-size: 80px; margin: 0; color: #ccc; background-image: url('/media/img_seria/1LG-504D12_2.jpg'); background-position: left 65%; background-repeat: no-repeat; background-size: 400px auto;"><i style="padding-left: 420px">⚙</i></h1>
|
||||
<h2 style="color: #333; font-size: 40px;">Технические работы</h2>
|
||||
<h4 style="color: #666; margin: 0 0 0 30px; font-size: 20px;">Приносим извинения. В данный момент сайт проходит техническое обслуживание. Мы скоро вернёмся!</h4>
|
||||
<p style="margin-top: 55px;"><a href="/">Вернуться на главную oknardia.ru</a></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -242,3 +242,66 @@ def get_address(request: HttpRequest) -> HttpResponse:
|
||||
'ticks': float(time.perf_counter() - time_start),
|
||||
})
|
||||
return render(request, "popup/popup_show_apartment_variants.html", to_template)
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# ОБРАБОТЧИКИ ОШИБОК ДЛЯ ТЕСТИРОВАНИЯ В DEBUG РЕЖИМЕ
|
||||
# ============================================================================
|
||||
# Используется в urls.py при DEBUG=True для тестирования верстки страниц ошибок.
|
||||
# Позволяет визуально проверить, как выглядят страницы 400, 403, 404 и 500
|
||||
# без необходимости искусственно вызывать реальные ошибки.
|
||||
|
||||
|
||||
def handler400(request: HttpRequest, exception=None) -> HttpResponse:
|
||||
"""Отображает страницу ошибки 400 (Bad Request).
|
||||
|
||||
Используется только в DEBUG режиме для тестирования верстки.
|
||||
|
||||
:param request: входящий http-запрос
|
||||
:param exception: исключение (если есть)
|
||||
:return response: исходящий http-ответ с кодом 400
|
||||
"""
|
||||
response = render(request, "error/400.html", {})
|
||||
response.status_code = 400
|
||||
return response
|
||||
|
||||
|
||||
def handler403(request: HttpRequest, exception=None) -> HttpResponse:
|
||||
"""Отображает страницу ошибки 403 (Forbidden).
|
||||
|
||||
Используется только в DEBUG режиме для тестирования верстки.
|
||||
|
||||
:param request: входящий http-запрос
|
||||
:param exception: исключение (если есть)
|
||||
:return response: исходящий http-ответ с кодом 403
|
||||
"""
|
||||
response = render(request, "error/403.html", {})
|
||||
response.status_code = 403
|
||||
return response
|
||||
|
||||
|
||||
def handler404(request: HttpRequest, exception=None) -> HttpResponse:
|
||||
"""Отображает страницу ошибки 404 (Not Found).
|
||||
|
||||
Используется только в DEBUG режиме для тестирования верстки.
|
||||
|
||||
:param request: входящий http-запрос
|
||||
:param exception: исключение (если есть)
|
||||
:return response: исходящий http-ответ с кодом 404
|
||||
"""
|
||||
response = render(request, "error/404.html", {})
|
||||
response.status_code = 404
|
||||
return response
|
||||
|
||||
|
||||
def handler500(request: HttpRequest) -> HttpResponse:
|
||||
"""Отображает страницу ошибки 500 (Internal Server Error).
|
||||
|
||||
Используется только в DEBUG режиме для тестирования верстки.
|
||||
|
||||
:param request: входящий http-запрос
|
||||
:return response: исходящий http-ответ с кодом 500
|
||||
"""
|
||||
response = render(request, "error/500.html", {})
|
||||
response.status_code = 500
|
||||
return response
|
||||
|
||||
Reference in New Issue
Block a user