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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:34:13+00:00 2026-06-09T14:34:13+00:00

How can I detect, from views or template file, if my admin user is

  • 0

How can I detect, from views or template file, if my admin user is logged in or not? For example, use case for my site:

  1. User opens /admin/, enter correct credentials
  2. Then user open some page, for example /page/ and there are “Add” and “Delete” buttons
  3. User opens /admin/ and click “Log out”
  4. /page/ -> there are no “Add” and “Delete” buttons

Django version 1.4

  • 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-09T14:34:14+00:00Added an answer on June 9, 2026 at 2:34 pm

    Joseph’s answer is fine for your simple case, but in reality neither is_staff nor is_superuser is a perfect fit. Assuming your page is, say, /polls/ (a list of Poll objects, in an app called poll), you should test the specific poll.change_poll and poll.delete_poll permissions.

    In a template:

    {% for poll in polls %}
        {% if perms.poll.change_poll %}<a href='/polls/edit/{{ poll.id }}'>Edit</a>{% endif %}
        {% if perms.poll.delete_poll %}<a href='/polls/delete/{{ poll.id }}'>Delete</a>{% endif %}
    {% endfor %}
    

    Or in a view using has_perm:

    if not request.user.has_perm('poll.change_poll'):
        return HttpResponseForbidden('Nope!')
    

    Or in a view using a decorator:

    @permission_required('poll.change_poll')
    def edit_poll(request, poll_id):
        # ....
    

    You can assign these permissions directly to a user, to a group (and then put a user in that group) or by setting is_superuser.

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

Sidebar

Related Questions

How can I detect the site the user came from before accessing mine in
How can I detect at compile time from an ASM source file if the
User can came from web or from devise (Android|iPhone|iPad|iPod) How correctly detect it?
how can me detect movie title from url.. http://www.mysite.com/2430-Moonrise-Kingdom.aspx http://www.mysite.com/2405-Dark-Shadows.aspx http://www.mysite.com/2415-Madagascar-3-Europes-Most-Wanted.aspx I need to
How can I detect when a JRadioButton is changed from 'unselected' to 'selected' when
How can I detect the start of my application from a completely terminated stated
My UIViewController is in a navigation stack. How can I detect when the user
I can detect that app is running under iOS Simulator (using sysctlbyname(hw.machine) ), but
I can detect my iPad device running an iPhone app in 1x or 2x
Is there anyway I can detect via jQuery if a select form element is

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.