Hey, welcome back.
In this video, you learn how to create admin interfaces for your Django apps.
So currently our Python, our Django app looks like this.
So we get data from the users, but there is no easy way to access those data.
As admins.
So we have to use like a third party app, like DB browser for SQLite to view the database records that
the user has submitted.
So we can fix that by having an admin interface.
So Django is made to actually make it easier for you to create admin interfaces.
So if you look inside job application, the app folder you will find an admin.py file.
So Django has already created a semi empty file, which now we need to add some more code, which is
very minimal code actually.
So all you need to do is you need to import from DOT models import form.
So dot models means this file models.py and form is the class that defines our database model.
So we import form and then down here we use this module admin which is imported up here.
Dot site dot register.
The register function expects a class to register it with the admin interface.
This class.
The module class.
You want to save that file and then to access the admin interface, you should go to your URL, but
add a slash and then admin and press enter and you'll see this view where the admins can log in.
Now in my case I have some pre-filled data here because I've built some other interfaces, other Django
programs, but you probably will see like an empty set of fields, a username and password.
So what's the username?
Where can you get the username and the password?
Well, for that you need to create a super user, an admin account basically.
So go to your terminal, stop the program with ctrl C and run python manage.py Create super user.
So it's one word.
No spaces you want to execute that and you should be asked to enter a username.
So I'll just enter my name press enter.
Then you want to specify an email address.
I'll just use the email address I was using for this app app.
Django.
It's not much important just for the records and press enter again to submit that.
Then the passwords and so I'll type in my password.
But note that the password is not visible, so I'm typing in as you can hear probably, and I don't
see any asterisk or the password.
So the password is being typed in, but it's hidden.
So once you're typing the password, then you want to press enter and then type in the same password
again just for confirmation, press enter again and you'll see this super user created successfully.
And then we want to run the app again with Python Manage.py run server.
Go to the admin interface.
Right.
So that's your URL.
And then you want to enter your username and your password.
Press login.
And this is what you should normally see.
So this is the site administration and you can have one or more admins to actually access this site.
So we have several links here such as groups and users.
So these are about the groups of users and the actual users themselves, like the user I've just created.
And then.
We have forms which you can access it from here or again from home.
So that's forms.
So this is the most important aspect of the admin interface.
So forms represents the form table where we have the user data.
So these are all the submissions I have received in my app.
So again, wherever the users enter here, that submission will be displayed in here, right?
So let's give it a try.
Let's try John Smith.
john@example.com
enter a date.
Student submit.
Form submitted successfully and then we can go to the admin interface.
You can reload this current link and then you'll see John Smith added there.
So each of them now each of these records here is clickable, which means you can click it and you will
see all the data.
So again, here we see the list of submissions and we only see the names in the list.
But then we have all these.
And as an admin you can also modify these fields.
It's also possible to make a field read only.
I'll show you how to do that in the next video.
So for now, this is all the default view.
So you can delete, you can change records and save it, and you can also add records on your own.
So you have this add button here, that one or that one, they do the same thing.
So add form and you can add records on your own.
So two ways to add a new job application, right?
So one through the websites as visitor and one manually as an admin in this interface.
So that's about how to create a default admin interface.
In the next video, I'll show you some tricks on how to customize the admin interface.
So we'll customize the list here and also make some fields reads only.
So let's see how we can do that in the next video.
See you there.