0
0
Djangoframework~30 mins

Creating superuser in Django - Try It Yourself

Choose your learning style9 modes available
Creating a Django Superuser
📖 Scenario: You are setting up a new Django project for a blog website. To manage the site easily, you need to create a superuser account that can access the Django admin panel.
🎯 Goal: Create a Django superuser with a username, email, and password so you can log in to the admin panel and manage the blog content.
📋 What You'll Learn
Create a Django project and app
Set up the database
Create a superuser with a specific username and email
Use the Django management command to create the superuser
💡 Why This Matters
🌍 Real World
Creating a superuser is essential for managing content and users in any Django web application.
💼 Career
Knowing how to create and use a Django superuser is a fundamental skill for backend developers working with Django.
Progress0 / 4 steps
1
Create a new Django project
Run the command django-admin startproject myblog in your terminal to create a new Django project named myblog.
Django
Need a hint?

Use the terminal or command prompt to run the command exactly as shown.

2
Navigate to the project directory and set up the database
Change directory to myblog using cd myblog and run python manage.py migrate to set up the database.
Django
Need a hint?

First move into the project folder, then apply migrations to create the database tables.

3
Create a superuser with username and email
Run python manage.py createsuperuser and when prompted, enter the username adminuser and email admin@example.com. Set a password when asked.
Django
Need a hint?

Use the createsuperuser command and type the exact username and email when prompted.

4
Run the development server and log in to admin panel
Start the server with python manage.py runserver. Open http://127.0.0.1:8000/admin/ in your browser and log in with username adminuser and your password.
Django
Need a hint?

Start the server and use the browser to access the admin login page.