How to register a superuser to access the Django admin panel

Django includes an admin panel as a standard feature, which allows for tasks such as updating table data.

In Django, after defining a table, you can register data for that table through the admin panel, which is convenient for testing during the development stage. To use the admin panel, you first need to register a superuser.

You can register a superuser by running the following command in the directory where 'manage.py' file is located.

python manage.py createsuperuser

If you're using Docker Compose, use the following command.

docker-compose run web python manage.py createsuperuser

You will be prompted to enter a username, email address, and password, so go ahead and input those.

You can access the admin panel at the following URL, and log in using the username and password you just entered. (The example below uses port 8000)

http://localhost:8000/admin/

おすすめの記事