×
   ❮   
PYTHON FOR DJANGO DJANGO FOR BEGINNERS DJANGO SPECIFICS PAYMENT INTEGRATION API BASICS Roadmap
     ❯   

CUSTOM USER MODEL

Creating & Managing Superusers

Creating and Managing Superusers

Superusers are users who have all permissions and can manage all aspects of a Django application via the admin interface. In this section, we'll cover how to create and manage superusers in your custom User model.

Creating a Superuser

To create a superuser with your custom User model, use the createsuperuser management command:


python manage.py createsuperuser

During the creation process, you will be prompted to enter a username, email address, and password. Ensure that the password meets the validation criteria defined in your settings.

Managing Superusers in the Admin Interface

After creating a superuser, you can log into the admin interface using the credentials you provided. You can manage users, groups, permissions, and site settings from the admin dashboard.

Updating Superuser Status

If you need to modify an existing user's superuser status, you can do this directly in the Django admin interface:

  • Go to the Users section in the admin panel.
  • Select the user you want to edit.
  • Check the boxes for Staff status and Superuser status to grant those permissions.

Alternatively, you can update the user programmatically:


user.is_superuser = True
user.is_staff = True
user.save()

Best Practices

While superusers have powerful permissions, it’s essential to limit the number of superusers to reduce security risks. Only assign superuser status to trusted individuals and regularly review user permissions.


Django-tutorial.dev is dedicated to providing beginner-friendly tutorials on Django development. Examples are simplified to enhance readability and ease of learning. Tutorials, references, and examples are continuously reviewed to ensure accuracy, but we cannot guarantee complete correctness of all content. By using Django-tutorial.dev, you agree to have read and accepted our terms of use , cookie policy and privacy policy.

© 2024 Nischal Lamichhane. All Rights Reserved.
Django-tutorial.dev is styled using Bootstrap 5.
And W3.CSS.