4. Admin
In this lesson we are going to enable the Django admin panel so that we can add articles from the web interface.
Add the following code to my_blog/admin.py:
from django.contrib import admin
from .models import Article
admin.site.register(Article)
An admin panel has now been created so that you can add, edit, and delete articles.
Go to http://localhost:8000/admin/.
Oops! What is the password? Don't worry, we are going to create a superuser.
docker compose run --rm django python manage.py createsuperuser
Follow the instructions and you can now log in to the admin panel. You can make up the email, the important thing is that you remember the username and the password. Don't worry about your data, everything that happens between you and Django stays on your computer. You are storing all the information in your local database, specifically in a file called db.sqlite3 at the root of your project.
You can now add some articles. Go back to http://localhost:8000/admin/, use the username and password you created, and add some articles.
We recommend that you add some of the most important women in the history of computing:
There is no point in having data in a database if we don't display it on the web page.
Let's display the list you just inserted on the main page.
This work is under a Attribution-NonCommercial-NoDerivatives 4.0 International license.
Desafíos de programación atemporales y multiparadigmáticos
Te encuentras ante un librillo de actividades, divididas en 2 niveles de dificultad. Te enfrentarás a los casos más comunes que te puedes encontrar en pruebas técnicas o aprender conceptos elementales de programación.
Buy the bookWill you buy me a coffee?
This is how I keep writing without ads or paywalls.
Sure, it's on me!
Comments
There are no comments yet.