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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:55:47+00:00 2026-06-03T17:55:47+00:00

I have to change the is_staff option from views.py file to disabling the Django-admin

  • 0

I have to change the “is_staff” option from views.py file to disabling the Django-admin page but i am not able to figure out this following issue.
Whenever i tried to write “user.is_staff” then it sound that there is not any option to choose it (is_staff) whereas is_active is present. is this problem of importing?

Following are the content which i am importing:

from django.contrib.auth.decorators import login_required
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.contrib.auth.models import User
from django.http import HttpResponseForbidden, HttpResponse
from django.shortcuts import get_object_or_404
from django.views.generic.list_detail import object_detail
from django.views.generic.simple import direct_to_template
from django.utils.translation import ugettext as _
from django.core.mail import send_mail
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger

from django.contrib import admin
from django.contrib.auth.admin import UserAdmin

Following code i wrote in views.py:

def user_change_status(request, id):
user = User.objects.get(pk=id)
    if user.is_staff:
       user.is_staff = False
    else:
       user.is_active = True
return HttpResponse('')

Whole scenario is that i have a template which is showing the list of all user with his/her is_staff option (True/ False). What i want when superuser will select any of user is_staff option it become change and the page will redirect on the same page.

After editing:
Two method are defined in views.py:

def user_change_status(request, id):
user = User.objects.get(pk=id)
if user.is_active:
    user.is_staff = False
else:
    user.is_staff = True
user.save()
value2 = user.is_staff
return HttpResponse(value2)

and another one is `

def user_block(request, id):
user = User.objects.get(pk=id)
if user.is_active:
    user.is_active = False
else:
    user.is_active = True
user.save()
value1 = user.is_active
return HttpResponse('value1')    

I want to change the is_staff value and is_active value. Method user_change_status is not working whereas user_block does.

  • 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-03T17:55:54+00:00Added an answer on June 3, 2026 at 5:55 pm

    Python is a dynamic language. In particular, it’s not Java or C++. As a rule, IDEs do very badly in autocompleting in dynamic languages.

    It’s a complete mistake to take any notice of what your IDE does or doesn’t offer as autocomplete options. Sometimes it’ll get it right, other times it won’t. Sometimes it’ll offer options that aren’t members of the object at all.

    Use the documentation, not your IDE.

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

Sidebar

Related Questions

Is it possible to have an enum change its value (from inside itself)? Maybe
So I'm using django and I have a page/template that looks like (simplified to
I Have site change.is, where right side menu & search bar in header is
I have a change password script in PHP and I want to do is
Is it possible to see which files have been changed whenever an change-event is
I have capture change event on drop down select. This drop down field is
This is to create a greeting card application and here i have to change
I have a JSON-like data structure (which I don't want to change) that is
I have regexp to change smileys to images. Here it is (?:(?![0]:\)|:\)\)|:-\)\)))(:\)|:-\)) The point
i have the following xml. legacy: xml (can't change because it is externalize). <bean

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.