Okay.
In this video, I will show you how to see what's inside our database.
And for this we'll use built in Django admin view.
So if we go to our chrome, this is our admin view and the URL for this is this 127 001 which is localhost
and then 8000 port and then slash admin.
And you can see here it's a login page.
At the moment we don't have any credentials and we can't, can't login in the Django administration
here.
The reason for this is we don't have a user in our system and we'll create a user on our system.
I will show you how to do it and then how we can actually access this and manage Django administration.
Okay.
So let's go back to our IDE and let's create a user.
So we are inside our terminal in IDE and I can run command in a similar way.
We run it before.
So Python.
Three or just python if you have one installed on your machine.
Manage pi and then create super user.
Altogether create super user.
And then we click enter.
And then we have some message here about three unapplied migrations and the admin and out.
And then they ask us to run the command python manage.py migrate.
We already did it so we'll kind of ignore it for now.
So basically this so actually might not have this displayed, but running this command, it will ask
us for a few things.
So basically first thing will be the username.
If you will leave it blank, it will be the same user as you have on your machine and I have a user
Christian, so I will leave it blank and I will click enter and then we have email address.
You don't need to type anything here, but if you like you can put your email address.
I will click Enter and then we need to set up a password.
I will set a password like my username Christian and then Christian and it's too similar to the username,
so I'll actually should create a different one.
But for our tutorial needs I can leave it as it is.
And because we are not really concerned about the security, but please don't put an application with
the same username and password on the production server because you will put your application at risk.
But we can bypass password validation and create user anyway.
I can click yes and then enter.
So we have created super user and we have that user with a username Christian and password Christian
available for us to use.
So that's been added to our database and that's an admin user.
So if I'll come back to the chrome.
We can see here.
Username is Christian and the password will be Christian the same way I've done it just a second ago
and I will log in here and I'm inside the Django administration.
So basically this screen allows me to see everything.
What's inside that database.
As soon I will add it to the Django administration.
And you can see here you have authentication and authorization.
If I go to the users, you can see my user here.
So I have a user and that's all information about my user I've created with create super user a command.
So I have groups and users available and I can add new users here, I can change and I can do a lot
of things here in that provided user interface, but we don't see our model the way that.
The model we have created here book is at the moment not available in the admin.
And the reason for this is we will need to add it manually to our admin file.
So let's open admin and you can register your models here.
So let's remove this and we can do admin side.
Register and then we can put the same name here, which is book.
So I will register here a book.
But at the moment it's underlined.
That means it's unresolved reference.
So we need to import so from.
Models.
That's in the same folder.
So dot models import book.
Once we import book, the red line is gone and then we do admin site register our model.
So if I will save it now.
And then we'll refresh the server.
I will go to the this view and I will refresh the page.
And you can see here the demo.
This is the name of our application.
And then inside the demo we have one model, one model called books.
And if I will go to the books, there is a zero books inside our database, but I can add book here
and you can see here title is this field we specified in our models.
So we have title and that's a char field maximum 36 character long.
And this user interface represents this setup from the file.
So we have a book with a title.
Let's add a book here and I will add for example, Hobbit, I can do Save, and this represents a new
record in our database.
I can click on this and I can see here I can change it so I can change anything here and then save it.
I can remove it from database or I can add more into it.
So this user interface allows us to manage our database.
So whatever you need to do on your database level, you can do it directly from here.
So sometimes the Django application for Django application, the Django administration user interface
will be enough for a application because if you want to store a simple records in the database and you
need a simple user interface, you can use Django administration for that.
You can log in with your super user and then you can add records, remove records and manage all records
in one place.
So in this video, I will show you how to use the Django administration and how to create a super user.