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.
This commit is contained in:
Benedikt Willi 2023-02-10 16:17:59 +01:00 committed by GitHub
parent b050ef76d3
commit 40fa4acdb4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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):