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

  • SEARCH
  • Home
  • 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 8565053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:20:10+00:00 2026-06-11T17:20:10+00:00

Here is the code in my base.html header <script> var auth_status = {{ user.is_authenticated

  • 0

Here is the code in my base.html header

    <script>
        var auth_status = "{{ user.is_authenticated }}"
    </script>

    {% block scripts %}  {% endblock %}

The rest of the scripts in my site are in the block scripts.

In a child template (within the script block and within script tags) I have this code,

         if (auth_status) {
          //something
         }

The error at hand is auth_status is always True, when it should be on and off depending on if the user is logged in. Request_context is being passed to the template so that should not be the error.

Thanks

  • 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-06-11T17:20:12+00:00Added an answer on June 11, 2026 at 5:20 pm

    For what I see your auth_status variable seems to be a string, not a boolean. A variable with a non-empty string on javascript will evaluate to true on an if clause.

    Anyhow, something like

    <script>
        var auth_status = {{ user.is_authenticated }};
    </script>
    

    will not work because that will generate this HTML:

    <script>
        var auth_status = True;
    </script>
    

    As Python’s True boolean is uppercased.

    This should do the translation from Python to Javascript:

    <script>
        var auth_status = {{ user.is_authenticated|yesno:"true,false" }};
    </script>
    

    Check yesno docs here: https://docs.djangoproject.com/en/dev/ref/templates/builtins/#yesno

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

Sidebar

Related Questions

Yo so i have a base.html: <html> <body> <div id=header> ... </div> {% block
Here is my code: class MyTestCase(Base): def setUp(self): #some code here def test_B(self): #some
i need a Function Pointer from a base class. Here is the code: class
The script is on jsfiddle here : CODE What it does at the moment
Below is an existing jquery code in our code base. $(#download_).click( function() { $(#error).html('');
I'm getting more into jQuery and so have set up a HTML/Javascript/CSS base site
UPDATE : The full site code is here - https://github.com/eWizardII/PeerInstruction I have the following
Ok the error is showing up somewhere in this here code if($error==false) { $query
Here is code my jqgrid editing through form. $(#DataEnergy).jqGrid('navGrid', '#pagergrid', {}, //options {editdata: {
Here my code, I need to insert into mysql database I have mysql,php,android 1)

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.