Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3439078
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:15:53+00:00 2026-05-18T08:15:53+00:00

I am using django-registration, and just set it up. {{user.is_authenticated }} is true, even

  • 0

I am using django-registration, and just set it up.

{{user.is_authenticated }}

is true, even though i went already to /accounts/logout/ and logged the user out.

{{user.is_anonymous }} 

returns true also. According to django docs, those two should be different:

is_anonymous: Always returns False. This is a way of differentiating User and AnonymousUser objects. Generally, you should prefer using is_authenticated() to this method.

and

is_authenticated: Always returns True. This is a way to tell if the user has been authenticated. This does not imply any permissions, and doesn’t check if the user is active – it only indicates that the user has provided a valid username and password.

I am using the standard views that come with django-registration and haven’t touched them yet. In the tempalate i have the following code:

{% if user.is_authenticated %}
{% user }}
{% if user.is_anonymous %}
    is anonymous
{% endif $}
{% else %}
    gotta login
{% endif %}

Where would the problem be? I will be really thankful!

UPDATE:
i have noticed that on the homepage, it both is_authenticated and id_anonymous return True, while if i go to /accounts/login before loging in, only is_anonymous returns true as it should be. And also, on the homepage, i have the following view if that helps:

def home(request):
    return render_jinja(request, 'index.html', blah = 'ga')

UPDATE 2:
print(request.user.is_authenticated()) gives False. Then, i have:

return render_jinja(request, 'index.html', blah = 'ga')

and in the template, user.is_authenticated returns FALSE.

UPDATE 3:
If i use render_to_response, instead of render_jinja, all is good. still don’t know how to fix this though 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:15:54+00:00Added an answer on May 18, 2026 at 8:15 am

    It seems like you are trying to figure out two things at once; what is the correct way to use jinja templates and what is the deal with User/AnonymousUser. Maybe try to figure out these problems one at a time.

    I have no experience with jinja but you may want to check and make sure that you are taking differences between jinja and django template syntax into account. The biggest difference I know of is that a method call requires explicit parenthesis. So the is_authenticated and is_anonymous calls in your example need parenthesis.

    Jinja style {{ user.is_authenticated() }}
    Django style {{ user.is_authenticated }} 
    

    If that does not solve the problem, try installing django-debug-toolbar and take a look at the context for your template. Check and see if user is None or an object (User or AnonymousUser).

    You can also read up on AnonymousUser and see an example of checking for an authenticated user in the docs. In a nutshell, for an AnonymousUser object is_anonymous() always returns True instead of False and is_authenticated() always returns False instead of True.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the Django Registration class, it's great, but the last version shipped with
I am currently working an a webapp, using mongoengine and django, which will require
I'm looking for a simple Django app that restricts registration to users who have
Im using Django 1.2.3. I have login functionality in my site using django.contrib.auth.views.login .
I am writing a website using Django. I need to push the web site
I have seen various questions on multi-site and multi-host Django, including subdomains and specific
I have a page, index.html, that contains both a login and registration form. I
I want to try Mongodb w/ mongoengine. I'm new to Django and databases and
Either my google searching has completely left me or there's hardly any documentation/tutorials for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.