I did a custom loginView and I can't reach the extra_context dictionary in my template. (authentification works fine)
my view file:
from django.contrib.auth import login
from .models import EsportUser
class LoginViewCustom(LoginView):
#esport_user = EsportUser.objects.first()
#extra_context = {'test42': esport_user}
template_name = 'users/login_register.html'
extra_context = {'test42': 'test'}
my template file (login_register.html):
<a href="#">{% trans "Account" %} {{ test42 }}</a>
my urls file:
path('login/', views.LoginViewCustom.as_view(), name='login', ),
Thanks, Stéphane
It's not too late to share a good answer:
Check out this similar question , basically you can pass your additional extract context the as_view()
method when calling it in the url.
So in your url.py
file, you can have something like this :
path('login/', views.LoginViewCustom.as_view(extra_context={'test42': 'test'}), name='login', )