/
dstemnik
/
DSServices
Обзор
Документация
Войти
/
dstemnik
/
DSServices
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
test_app/views_admin.py
17 строк
617 B
Tem
first commit
03 дек 2025, 11:03
03 дек 2025, 11:03
8cd0ecb
Код
Авторство
О чём код?
from django.shortcuts import redirect from django.utils.http import url_has_allowed_host_and_scheme from .models import WBStore def select_active_store(request): store_id = request.POST.get("store_id") try: store = WBStore.objects.get(id=store_id) request.session["active_store_id"] = store.id except WBStore.DoesNotExist: request.session["active_store_id"] = None next_url = request.META.get("HTTP_REFERER") if not next_url or not url_has_allowed_host_and_scheme(next_url, allowed_hosts={request.get_host()}): next_url = "/admin/" return redirect(next_url)