Chapter 2. Django Quick Start

Create Superuser and Log In to Django Admin

Create Superuser and Log In to Django Admin
Tag:

To log in to the Django admin site, you need to create a superuser by running the createsuperuser command.

The createsuperuser command

Run the command below to create a superuser for the Django admin.

Command Line – INPUT
python manage.py createsuperuser

You'll be asked to type a username, an email address, and a password. Django also checks password strength.

Command Line - INTERACTIVE
Username: ■■■■■■■■
Email address: ■■■■■■■■
Password:
Password (again):
The password is too similar to the username.
This password is too short. It must contain at least 8 characters.
Bypass password validation and create user anyway? [y/N]: y
Superuser created successfully.

Log-in to Django admin page

You can log in to the Django admin page using the username and password you created.

Go to 'localhost:8000/admin/' in your browser, and type your username and password.

Create-Superuser

Create a normal user

You can also create a normal user on the admin site. On the Users page, you can find the user you created. You can create other users by clicking on the ADD USER + button on the top right.

Type a username and password on the page, and press the SAVE button to create a new user.

Create-Superuser

After creating a user, you'll go to the Change user page. On the page, you can modify permission settings. As a default, the user is registered as a normal user who cannot access the Django admin site. If you want to make the user acces the admin site, check the Staff status. If you want to give the superuser status, which enables access to all resources of the app, check the Superuser status.

Create-Superuser

If you go down on the Change user page, you'll see more detailed permission settings, including group settings. We don't explain these features here, but you can understand that Django has quite robust user permission features already. This is one of the key advantages of using the Django framework for your web app development.

To log in to the Django admin site, you need to create a superuser by running the createsuperuser command.

The createsuperuser command

Run the command below to create a superuser for the Django admin.

Command Line – INPUT
python manage.py createsuperuser

You'll be asked to type a username, an email address, and a password. Django also checks password strength.

Command Line - INTERACTIVE
Username: ■■■■■■■■
Email address: ■■■■■■■■
Password:
Password (again):
The password is too similar to the username.
This password is too short. It must contain at least 8 characters.
Bypass password validation and create user anyway? [y/N]: y
Superuser created successfully.

Log-in to Django admin page

You can log in to the Django admin page using the username and password you created.

Go to 'localhost:8000/admin/' in your browser, and type your username and password.

Create-Superuser

Create a normal user

You can also create a normal user on the admin site. On the Users page, you can find the user you created. You can create other users by clicking on the ADD USER + button on the top right.

Type a username and password on the page, and press the SAVE button to create a new user.

Create-Superuser

After creating a user, you'll go to the Change user page. On the page, you can modify permission settings. As a default, the user is registered as a normal user who cannot access the Django admin site. If you want to make the user acces the admin site, check the Staff status. If you want to give the superuser status, which enables access to all resources of the app, check the Superuser status.

Create-Superuser

If you go down on the Change user page, you'll see more detailed permission settings, including group settings. We don't explain these features here, but you can understand that Django has quite robust user permission features already. This is one of the key advantages of using the Django framework for your web app development.

Tag: