How to Create Superuser in Django?

Published On: 09/01/2023 | Category: Django


Hi Dev,

In this example, we will discuss talk about how to create superuser in django.so, here in this short tutorial we will learn about django create a superuser in django.

In Django admin site is dynamically built by reading your model metadata and providing a production-ready interface for content editing. You can use it right away, configuring how your models are displayed in it.

So, you have must migrate your project first, otherwise the superuser will not creating the database.

Here i will give you we will help you to give example of how to create superuser in django. So let's see the bellow example:

Creating the Superuser

Execute the following command in the directory containing the manage.py script.

python manage.py createsuperuser

Now Django will prompt you to enter the details; enter the details you want and press enter.

Username (leave blank to use 'admin'): admin
Email address: [email protected]
Password: ********
Password (again): ********
Superuser created successfully.
Run the Server

In this step, we’ll run the local development server for playing with our app without deploying it to the web.

python manage.py runserver

Next, go to the http://localhost:8000/admin/ address with a web browser enter the username and password to generate through command.



I Hope It will help you....