![]() |
VOOZH | about |
Django comes with a built-in admin panel that helps developers manage the database, users, and application models efficiently, without needing a separate interface. To access and use the admin panel, a superuser must be created.
Before creating a superuser, ensure your project has been migrated to set up necessary database tables. Follow these steps to create a Superuser:
Open terminal or command prompt and move to the directory where your manage.py file is located.
cd path/to/your/django/project
Execute the following command to initiate the superuser creation process:
python manage.py createsuperuser
The system will prompt you to enter details for the superuser:
Username: admin
Email address: admin@example.com
Password: ********
Password (again): ********
If all fields are entered correctly, Superuser created successfully.
Once the superuser is created, follow these steps to log in:
1. Start the Django development server:
python manage.py runserver
2. Open web browser and navigate to the Django admin login page:
http://127.0.0.1:8000/admin/
3. Enter the Username and Password you set while creating the superuser.
Click Login, and you will be redirected to the Django Admin Dashboard, where you can manage your application’s models, users and data.
1. Changing Superuser Password: If the superuser password is forgotten, reset it using:
python manage.py changepassword <username>
2. Creating Multiple Superusers: Additional superusers can be created by running the createsuperuser command again.
3. Managing Users via Shell: Superusers can also be created or managed from the shell:
python manage.py shell
from django.contrib.auth.models import User
User.objects.create_superuser('newadmin', 'admin@example.com', 'securepassword')
Related Articles: