JourneyJoker/frontend/views.py

17 lines
515 B
Python

from django.shortcuts import redirect
from django.utils.translation import LANGUAGE_SESSION_KEY
from django.views.generic import TemplateView
# Create your views here.
class IndexView(TemplateView):
template_name = "frontend/index.html"
def change_language(request):
url = request.GET.get('url', '/')
language = request.GET.get('language', 'de')
if "://" in url:
raise ValueError("This is not a de-referer.")
request.session[LANGUAGE_SESSION_KEY] = language
return redirect(url)