Admin Portal

One of the coolest things that Django has to offer is this Admin portal. It allows you to interact directly with your database and see what's going on in the back end.

Creating a SuperUser

First, you need to create a SuperUser. This is just an account for you to log into the admin portal.

Enter the following command in the terminal:

 python manage.py createsuperuser

The URL is just the /admin. Enter this in your browser:

http://127.0.0.1:8000/admin

Registering our Models in the Database

We need to tell Django what we want it to display to us in the Admin Portal. To do so, enter the following code in database/admin.py

from django.contrib import admin
from database.models import Post, Like
# Register your models here.

admin.site.register(Post)
admin.site.register(Like)

Using the Admin Portal

The portal is pretty easy to use -- just click around and see what it can do.

Lets create a few posts!

results matching ""

    No results matching ""