django admin create superuser
To create a superuser in Django admin, follow these steps:
Open Terminal/Command Prompt: Access the command line interface for your project.
Navigate to Your Django Project Directory: Use the
cd
command to move to your Django project directory where themanage.py
file is located.Activate Virtual Environment (if applicable): If you're using a virtual environment, activate it using the appropriate command (e.g.,
source venv/bin/activate
for Unix-based systems orvenv\Scripts\activate
for Windows).Run the
createsuperuser
Command: Execute the following command:python manage.py createsuperuser
Enter Username: When prompted, type the desired username for the superuser and press Enter.
Enter Email Address: Provide the email address for the superuser and press Enter.
Enter Password: Enter a strong password for the superuser. As you type, the characters won't display on the screen for security reasons. Press Enter once you've typed the password.
Confirm Password: Confirm the password by typing it again and pressing Enter.
Superuser Created: You'll receive a confirmation message indicating that the superuser has been created successfully.
Access Django Admin: Start the Django development server (
python manage.py runserver
) if it's not running already. Then, in a web browser, go to the admin page (http://127.0.0.1:8000/admin
by default) and log in using the superuser credentials you just created.
That's it! You've successfully created a superuser in Django admin, granting access to the admin interface with elevated privileges.