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 792093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:56:22+00:00 2026-05-14T21:56:22+00:00

In my base.html file, I am using {% if user.is_authenticated %} <a href=#>{{user.username}}</a> {%

  • 0

In my base.html file, I am using
{% if user.is_authenticated %}
<a href="#">{{user.username}}</a>
{% else %} <a href="/acc/login/">log in</a>

Here, even if the user is logged in, the log in button shows up.

Now when I click on the log in link, it shows the username and also the normal login view, saying user is logged in.

So, what’s wrong?

  • 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-14T21:56:22+00:00Added an answer on May 14, 2026 at 9:56 pm

    Sounds like you’re not getting any user information in your templates. You need 'django.contrib.auth.middleware.AuthenticationMiddleware' in your MIDDLEWARE_CLASSES setting, and to get that goodness in context for your templates, you need to do:

    from django.shortcuts import render_to_response
    from django.template import RequestContext
    
    def my_view(request):
        return render_to_response('my_template.html',
                                  my_data_dictionary,
                                  context_instance=RequestContext(request))
    

    To save you doing this everywhere, consider using django-annoying’s render_to decorator instead of render_to_response.

    @render_to('template.html')
    def foo(request):
        bar = Bar.object.all()
        return {'bar': bar}
    
    # equals to
    def foo(request):
        bar = Bar.object.all()
        return render_to_response('template.html',
                                  {'bar': bar},
                                  context_instance=RequestContext(request))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my base.html I placed this: {% if user.is_authenticated %} you are logged in!
I have a file called header.html and it is included by base.html . In
Here is an example of polymorphism from http://www.cplusplus.com/doc/tutorial/polymorphism.html (edited for readability): // abstract base
I am using Django's Template Fragment Caching so in a template.html file {% extends
I'm handling the onChange event of an HTML input file field by using jQuery's
I have a base.html template that contains a list of links. Example: <div id=sidebar1>
i have template base.html and some children templates. I don't know how to set
Like a good little coder, all of my Django templates inherit from a base.html.
As in http://nant.sourceforge.net/release/latest/help/functions/nant.get-base-directory.html , they explaint the meaning of this function is: The base
I have a ListView. If I want to base the html markup on a

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.