Search code examples
pythondjangoroot

Django: How to programatically change superuser and/or staff status of a user


I'm creating an admin interface for a customer (separate from the supplied Django admin interface), and I need a way to change a user's superuser/staff status.

I can fetch the User object for a specified user, but I don't know how to change the superuser/staff status for that User.

Not surprisingly, doing

user.is_superuser = False

didn't work.


Solution

  • See Scott Woodall's comment above. I forgot to do:

    user.save()
    

    which commits the changes.