Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Create a Superuser in Django

Make the admin account you need to sign in to the Django admin site.

How-To Guides2 min read9 steps9 screenshots

What a superuser is

A superuser can do everything in the Django admin interface. You make one with the command createsuperuser. You need a working Django project first.

Install Django on Linux

  1. Install Python 3:
sudo apt install python3
Installing Python 3
  1. Install Django with pip:
pip install django
Installing Django

If pip is missing, install it with sudo apt install python3-pip. A virtual environment keeps each project clean.

Create a project and the superuser

  1. Create a folder:
mkdir my_django_project
Creating the folder
  1. Go into it:
cd my_django_project
Opening the folder
  1. Start a project:
django-admin startproject my_project
Creating the Django project
  1. Go into the project:
cd my_project
Opening the project
  1. If you use a virtual environment, activate it. Create one with python3 -m venv myenv and then:
source myenv/bin/activate
The virtual environment is active
  1. Apply the migrations. Without them the user table does not exist:
python manage.py migrate
Applying migrations
  1. Create the superuser:
python manage.py createsuperuser
Running createsuperuser

Django asks for a user name, an email address and a password. Type the password twice. Then start the server and open the admin page:

python manage.py runserver

Visit http://127.0.0.1:8000/admin/ and sign in.

Main parts of Django

  • Models define your data and the database tables.
  • Views handle requests and send answers.
  • Templates control how pages look.
  • URLs link addresses to views.
  • Forms check what users type.
  • Admin is the ready-made site to manage your data.

Why people use Django

  • Fast development, because Django reuses code (the DRY idea).
  • A built-in admin site.
  • An ORM that makes database work easier.
  • Many security features by default.
  • It scales well and has a large community.

Quick recap

  • Install Django, create a project and run migrate.
  • Run python manage.py createsuperuser.
  • Sign in at /admin/.