Ok Here goes.
With django-registration i have created a user with passwords etc.
I have named the user Zoro. The registration was a success and it takes me to
“You are now registered. Activation email sent.”
Email activation is turned off. So i go to login page and login. This is done under 127.0.0.1/accounts/login. The login.html template successfully extends the base.html template. And within the base.html template i have a tag {{ user }}, which i want to show the username at the top left.
When i login my urls are extended away from ^/accounts/login to ^/homepage. Know i dont know where the current username is stored, so i cant pass to {{ user }} the curent user’s name in views. So {{ user }} is blank.
But…….If i go back to the login page, the current username is at the top left.
I am new, be gentle.
You have different options to add the
{{ user }}to your templates context:a) add
django.contrib.auth.context_processors.authto yourTEMPLATE_CONTEXT_PROCESSORSsetting. This will make a{{ user }}template variable available in all context’s when rendering templates.b) do it by hand and add a
uservariable to pass it to the context in your view.usercan be retrieved fromrequest.userc) Make sure you are not overwrting
{{ user }}somewhere.