django admin create superuser

To create a superuser in Django admin, follow these steps:

  1. Open Terminal/Command Prompt: Access the command line interface for your project.

  2. Navigate to Your Django Project Directory: Use the cd command to move to your Django project directory where the manage.py file is located.

  3. 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 or venv\Scripts\activate for Windows).

  4. Run the createsuperuser Command: Execute the following command: python manage.py createsuperuser

  5. Enter Username: When prompted, type the desired username for the superuser and press Enter.

  6. Enter Email Address: Provide the email address for the superuser and press Enter.

  7. 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.

  8. Confirm Password: Confirm the password by typing it again and pressing Enter.

  9. Superuser Created: You'll receive a confirmation message indicating that the superuser has been created successfully.

  10. 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.