What is Django Admin?
DJANGO ADMIN
django-admin
is Django’s command-line utility for administrative tasks. This document outlines all it can do.
In addition, manage.py
is automatically created in each Django project. It does the same thing as django-admin
but also sets the DJANGO_SETTINGS_MODULE
environment variable so that it points to your project’s settings.py
file.
To add, edit, and delete the posts we've modeled, we will use the Django admin.
Let's open the first_app/admin.py
file in the code editor and replace its contents with this:
OK, time to look at our Post model. Remember to run in the console to run the webserver. Go to your browser and type the address http://127.0.0.1:8000/admin/. You will see a login page like this:
while the webserver is running, open a new terminal window and activate your virtualenv. you can check my article on it
in the terminal run this command
python manage.py createsuperuser
When prompted, type your username (lowercase, no spaces), email address, and password. Don't worry that you can't see the password you're typing in – that's how it's supposed to be. Type it in and press to continue. The output should look like this (where the username and email should be your own ones):
Username: ola
Email address: ola@example.com
Password:
Password (again):
Superuser created successfully.
Return to your browser. Log in with the superuser's credentials you chose; you should see the Django admin dashboard.
we will talk more about it in the next article