← Back to Django Course | Chapter 8: Django Admin | Lesson 2 of 8

Creating a Superuser

A superuser is the master account that can log in to the admin dashboard and manage everything.

Running createsuperuser

The createsuperuser management command walks you through setting a username, email, and password, then saves a User row with full admin rights.

Example: Running createsuperuser

This starts the interactive prompt; answer the username/email/password questions to finish.

bash
python manage.py createsuperuser

⚠️ Run this command in your terminal.

What Makes an Account a Superuser

Behind the scenes, createsuperuser just sets two boolean flags on the User model: is_staff lets the account log in to /admin/, and is_superuser grants every permission without needing individual ones assigned.

Example: What Makes an Account a Superuser

Inspecting the created user in the shell confirms both flags were set to True.

bash
python manage.py shell
>>> from django.contrib.auth.models import User
>>> u = User.objects.get(username='admin')
>>> u.is_staff, u.is_superuser
(True, True)

⚠️ Run this command in your terminal.

Logging In and Confirming Access

Once the superuser exists, start the dev server and log in at /admin/ with those credentials to confirm the dashboard loads.

Note: If the login page rejects a correct password, double-check is_active is True on that user.

Example: Logging In and Confirming Access

Starts the dev server so you can visit http://127.0.0.1:8000/admin/ and log in.

bash
python manage.py runserver

⚠️ Run this command in your terminal.

Common Mistakes
  1. Trying to log in to /admin/ with a regular user account that was never granted staff or superuser status.
  2. Forgetting the password immediately after creating the superuser in a non-interactive script.
  3. Creating a new superuser every time instead of reusing the existing one, ending up with several admin accounts.
Chapter Summary
  • python manage.py createsuperuser starts an interactive prompt for username, email, and password.
  • A superuser automatically has is_staff=True and is_superuser=True, granting full admin access.
  • You need at least one superuser before the admin dashboard is usable.

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.