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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T08:50:29+00:00 2026-06-09T08:50:29+00:00

I have a written views in django where i have more than one tab

  • 0

I have a written views in django where i have more than one tab on the web page. Some of them I want to make invisible for those user whose is_staff status is False. Following is the code

   TOP_NAVIGATION_BAR = [ {'name':'home', 'href':'/my_app/home',active:False},
                          {'name':'Content', 'href':'/my_app/content',active:False},
                          {'name':'Secure', 'href':'/my_app/Secure',active:False},
                        ]

   class topnavigationbar:
         tab = TOP_NAVIGATION_BAR
         def set_active_tab(self, tab_name):
             for tab in self.tabs:
                if tab['name'] == tab_name:
                   tab['active'] = True;
                else:
                   tab['active'] = False;

         def __init__(self, active_tab):
             self.set_active_tab(active_tab)

For every view i set the top_navigation_bar active option= True.

Now I want that Secure tab should not be visible to users whose is_staff status is False.
How and where can i write the query for that?
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-09T08:50:35+00:00Added an answer on June 9, 2026 at 8:50 am

    Another solution (involving not modifying the arguments to __init__(), which may be troublesome) is to define which URLs need is_staff in TOP_NAVIGATION_BAR, like this:

    TOP_NAVIGATION_BAR = [
        {{'name': 'Secure', 'href': '/my_app/Secure', active: False, secure: True},
        ...
    ]
    

    Now, you can carry out the check itself in the template (assuming your navigation menu appears in the template as the nav_menu context variable):

    {% for menu_item in top_menu %}
    {% if not menu_item.secure or request.user.is_staff %}
        <a href='{{ menu_item.href }}' ...
    {% endif %}
    {% endfor %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the view function in django that written like a dispatcher calling other
I have a number of manually written scripts (.sql) for tables, views and stored
I have written a simple feedback application in django. It's not particulairly complex, basically
i am fairly new to django and i want to update some of my
I have a blog written in Django, and I started using the basic Django
Have written some RoR sites in the past, but never bothered too much at
I'm creating Django application, with forum-like thingy. One of the views should display list
I am developing my first django website. I have written code in my view
I have written a small unit test for my django view .My project structure
I'm using Django and have a form with two additional inline formsets. I want

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.