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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:08:50+00:00 2026-06-07T04:08:50+00:00

Django has list_editable . I need to edit is_active flag. from django.contrib.auth.models import User

  • 0

Django has list_editable. I need to edit is_active flag.

from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin
from django.contrib import admin
from django.db.models import Q
from django import forms

class MyUserAdminForm(forms.ModelForm):
    class Meta:
        model = User

    #def clean_is_active(self):
        # do something that validates your data
    #    print ' I am here... '
    #    print self.cleaned_data
    #    print self
    def clean(self):
        k = 1


class MyUserAdmin(UserAdmin):
    list_display = ["id", "username", "email", "is_staff", "is_superuser", "is_active", "date_joined"]
    search_fields = ["username", "email"]
    list_display_links = ["id", "username"]
    list_editable = ("is_active",)
    list_per_page = 50

    form = MyUserAdminForm


# Had to unregister the User so it could be registered with MyUserAdmin
admin.site.unregister(User)
admin.site.register(User, MyUserAdmin)

I put this in admin.py, and I’ve registered my admin.ModelAdmin code. The display is fine. So MyUserAdmin is working fine.

This code should fail because of the clean method. But it didn’t. It isn’t using MyUserAdminForm apparently. I need to clean the is_active.

Thanks.


Note I have inherited from admin.ModelAdmin rather than UsreAdmin. I have used all the combinations I can have……


Update

I think this piece of code is only useful for the edit page, not for the list_editable option.

  • 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-07T04:08:53+00:00Added an answer on June 7, 2026 at 4:08 am

    Maybe the problem is that you should inherit your custom MyUserAdmin from UserAdmin from django’s admin models…

    Here you can find an example of how to do that: Customizing an Admin form in Django while also using autodiscover

    When you add a change like this, you should restart your server (restart manage.py or apache or whatever you are using)

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

Sidebar

Related Questions

from django.contrib.admin.actions import delete_selected from Test.app.models import Post from django.contrib import admin class PostModelAdmin(admin.ModelAdmin):
Django auth User model has a date_joined DateTimeField . Could this be used to
Django has various numeric fields available for use in models, e.g. DecimalField and PositiveIntegerField
I need to output objects in Django template, so that each object has its
I'm building my first django app. I have a user, and the user has
My django application has become painfully slow on the production. Probably it is due
Given that django-nonrel has got JOINs working, does this mean we have M2M fields
Now that django-sentry has become a standalone server (and is fantastic) I'm trying to
My friend says that Django only has 1 thread or something? And I have
I am making a custom form object in Django which has an overrided __init__

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.