How to create superuser in Django?
Last Updated :
17 May, 2025
Django comes with a built-in admin panel that allows developers to manage the database, users and other models efficiently. This eliminates the need for creating a separate admin interface from scratch. To access and manage the Django Admin panel, we need to create a superuser i.e. a user with full administrative privileges.
Prerequisites
Before creating a superuser, ensure that
python manage.py migrate
This step ensures that the necessary database tables, including those for authentication, are created.
Steps to Create a Superuser
To create a superuser in Django, follow these steps:
1. Navigate to the Project Directory: Open your terminal or command prompt and move to the directory where your manage.py file is located.
cd path/to/your/django/project
2. Run the Superuser Creation Command: Execute the following command to initiate the superuser creation process:
python manage.py createsuperuser
3. Enter Required Details: The system will prompt you to enter details for the superuser:
- Username: Choose a username for the superuser.
Username: admin
- Email Address: Provide an email address (optional, can be left blank).
Email address: [email protected]
- Password: Enter a secure password and confirm it when prompted.
Password: ********
Password (again): ********
Note: Ensure your password meets the security requirements set by Django. If it is too weak, Django may ask you to enter a stronger password.
4. Successful Superuser Creation: If all fields are entered correctly, you will see a confirmation message:
Superuser created successfully.
Image shown after above steps done Logging into the django admin panel
Once the superuser is created, follow these steps to log in:
1. Start the Django development server:
python manage.py runserver
2. Open your web browser and navigate to the Django admin login page:
http://127.0.0.1:8000/admin/
3. Enter the Username and Password you set while creating the superuser.
4. Click Login, and you will be redirected to the Django Admin Dashboard, where you can manage your application’s models, users and data.
Django admin pageAdditional Tips
- Changing Superuser Password: If you forget the superuser password, you can reset it using:
python manage.py changepassword <username>
- Creating Multiple Superusers: You can create additional superusers by repeating the createsuperuser command.
- Managing Users via Shell: If needed, you can create or manage superusers using the Django shell:
python manage.py shell
from django.contrib.auth.models import User
User.objects.create_superuser('newadmin', '[email protected]', 'securepassword')
Related Articles:
Similar Reads
How to create a Django project? Dive into the world of web development with Python by exploring the versatile Django framework. Django is a go-to for many developers due to its popularity, open-source license, and robust security features. It enables fast and efficient project development. In this tutorial, we will guide you throu
5 min read
How to Create an App in Django ? In Django, an app is a web application that performs a specific functionality, such as blog posts, user authentication or comments. A single Django project can consist of multiple apps, each designed to handle a particular task. Each app is a modular and reusable component that includes everything n
3 min read
How to create user from Django shell Let's look at how to create a user for Django using Django's interactive shell? Make sure you have the virtual environment activated, and you are within the folder that has the manage.py file. Note: Refer to the article How to Create a Basic Project using MVT in Django? to understand how to create
1 min read
How to use PostgreSQL Database in Django? This article revolves around how can you change your default Django SQLite-server to PostgreSQL. PostgreSQL and SQLite are the most widely used RDBMS relational database management systems. They are both open-source and free. There are some major differences that you should be consider when you are
2 min read
How to Create a Basic Project using MVT in Django ? Prerequisite - Django Project MVT Structure Assuming you have gone through the previous article. This article focuses on creating a basic project to render a template using MVT architecture. We will use MVT (Models, Views, Templates) to render data to a local server. Create a basic Project: To in
2 min read
How to use User model in Django? The Djangoâs built-in authentication system is great. For the most part we can use it out-of-the-box, saving a lot of development and testing effort. It fits most of the use cases and is very safe. But sometimes we need to do some fine adjustment so to fit our Web application. Commonly we want to st
3 min read