From 40fa4acdb4f5c29225115eb98d5ecf50fe0f87c6 Mon Sep 17 00:00:00 2001 From: Benedikt Willi Date: Fri, 10 Feb 2023 16:17:59 +0100 Subject: [PATCH] Update middleware.py Use reverse_lazy instead of reverse, as reverse('tos_check_tos') can return the URL in a wrong language (the language the current thread is in, instead of the language of the users request) in combination with i18n. --- tos/middleware.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tos/middleware.py b/tos/middleware.py index 9723e06..aac4678 100644 --- a/tos/middleware.py +++ b/tos/middleware.py @@ -3,7 +3,7 @@ from django.contrib.auth import SESSION_KEY as session_key from django.contrib.auth import REDIRECT_FIELD_NAME from django.core.cache import caches from django.http import HttpResponseRedirect -from django.urls import reverse +from django.urls import reverse_lazy from django.utils.cache import add_never_cache_headers from django.utils.deprecation import MiddlewareMixin @@ -11,7 +11,7 @@ from .models import UserAgreement cache = caches[getattr(settings, 'TOS_CACHE_NAME', 'default')] -tos_check_url = reverse('tos_check_tos') +tos_check_url = reverse_lazy('tos_check_tos') class UserAgreementMiddleware(MiddlewareMixin):