This page looks best with JavaScript enabled

Django Admin Interface

 ·  🎃 kr0m

Django greatly facilitates the management of database objects. In this article, we will see how, through the admin app, we can create/edit/delete exercises, routines, and users without having to write a single line of code.

Before we begin, it is recommended to read the previous articles on Django as they are the previous steps to this article:


Activate the project’s venv:

cd rxWod
source bin/activate
cd rxWodProject/

Now, create a superuser:

python manage.py createsuperuser

Nombre de usuario (leave blank to use 'kr0m')Dirección de correo electrónico: kr0m@alfaexploit.com  
Password:   
Password (again)Superuser created successfully.

Start the server and access the admin app:

python manage.py runserver

Access the admin interface:
http://localhost:8000/admin
kr0m/Password

You will see an interface like this:

For now, we only see users and groups:

Register the Exercice and Routine models in the admin interface so that we can manage the objects from it:

vi rxWod/admin.py

from django.contrib import admin
from .models import Exercise, Routine

admin.site.register(Exercise)
admin.site.register(Routine)

Go back to the admin interface and you will see that you can modify the database objects:

Now, we can start inserting exercises, but it is preferable to create an automatic insertion command to save time by not having to click. We will see this in future articles.

If we add an exercise, the following screen will appear with the fields of the model:

If, on the other hand, we create a routine, the following will appear:

If you liked the article, you can treat me to a RedBull here