If the user anonymous or not, how can i check that in base.html?
Which is correct?
{% if request.user.is_authenticated %}
Or
{% if user.is_authenticated %}
How can i pass the variable request.user in base.html?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try using the Request context:
Make sure you take a look at these context processors: https://docs.djangoproject.com/en/dev/ref/templates/api/#django-contrib-auth-context-processors-auth
And then you should be able to access
userin your templatesYou can use the django shortcut
renderto always render a template that is automatically passed a RequestContent:https://docs.djangoproject.com/en/dev/topics/http/shortcuts/#module-django.shortcuts