Welcome back, everyone, to this lecture covering Django Admin, just the very basics, what we're
going to do is explore Django administration, and there's typically two things that we want to check
out first.
One is the fact that if you were to go to your domain dot com, in our case, there's just one two seven
zero zero one port, eight thousand four slash admin.
You're going to realize that there's actually an extension already automatically created for you by
Django.
In fact, the whole Django admin system just comes and automatically built itself based off the models
and views you create.
It's an amazing feature that I really think is going to impress you when you realize you didn't have
to do any extra code in order to have this happen.
Then once we actually see that admin extension working, we're going to create a super user at the command
line using the managed PY file that can allow us to have a username and password to actually log in
to the admin view to get started.
I'm actually going to go to Django Project RT.com to show you what this admin looks like.
OK, here I am at Django Project comes the official page for the documentation.
What I want you to do is go to Django Project e-Comm and then say Forward Slash Admin, 80 m i n and
then hit enter.
And what you notice is it's actually going to reroute you to admin forward slash login because this
is the administration view for Django and you're technically not logged in yet.
In order to be authorized to actually see the administration of this Django site now, clearly we don't
have a username or password for this Django administration, but this is what the default Django administration
looks like.
Obviously, Django Project is running off of Django itself, and by default, Django actually creates
a Django administration page.
Let's see this on our site that we just created in the previous two lectures here at our site.
Remember, we have list, add and delete, and I can just add a new car.
For example, I can add a Ford from the year 2023.
Go ahead, submit.
And now that's added in.
What I'm going to do is instead of checking out the cars and list app.
I'm going to say our domain name, which is one two seven zero zero one 8000 and then go to forward
slash admin, I hit Enter.
And notice that we also have this Django administration page.
We didn't have to do any coding in order for this to just work right off the bat.
What we do need to do, though, is create up a username and password.
That combination of a username and password is known as a super user within Django.
This is to clarify the difference between a typical user of your website.
Maybe if you're running something like Facebook or Instagram, where a typical user is just someone
on their actual social network, a super user would be someone that actually has admin capabilities
and could possibly actually edit points in your models.
So let's see how this works in order to create a super user.
We have to go back to Visual Studio code and do it at the command line.
OK, here I am back at Visual Studio Code.
I have my site running, but in order to create a super user, I need to stop this right now.
So I'm going to say control.
See here.
Make sure the site's no longer running.
And then what I can do is, say, python managed dot pie.
And then the command is create super user all one word.
And obviously, this is a functionality command built into manage the pie that allows us to easily create
a super user, something to keep in mind.
Those after you run this, it's going to ask you for your inputs like a username, email address and
password and then confirmed that password.
I should also note the password is going to be invisible as you type it for security purposes.
That way, someone looking over your shoulder can actually know your password by just looking at the
screen.
So I hit Python, managed up high create super user, and what you can do is have it use your default
username from your actual computer.
You can see mine right there, Marcial.
But what I'm going to do is just create another username so we can understand that we were actually
the ones created.
So let's imagine I have a person on my team named Jan, and I want her to have an admin.
So I'm going to say Jan or Jane underscore admin is the username I enter, then her email address right
now, I'm just going to make this up.
Obviously, the point of this email address would be if this administrator ever needed to reset their
password, we could send them an email here.
So we'll just say Jan or Jane at.
Or, yeah, Tuscon, that's fine.
Enter.
And now it's time for the password.
There are going to be some limitations to this password.
It does have to meet a certain number of characters and can't be too simple.
So you can't really just type in password.
So we will just use a bad password.
I'm going to type in Jane Password J A and e p a se w o r d.
Again, keep in mind, it is invisible, and it's not apparent that I actually typed something there,
but I'm going to hit enter and now it's time for the password again.
So I'm just typing a and e p a S.W.O.R.D. Jane password, OK?
And if those didn't match, you would ask us to redo those passwords, but the super user has been created
successfully.
Again, one of the most common questions I get is why is my password not typing anything?
It's invisible for security purposes.
So we just created this super user Jane Admin with Jane Password as the password.
And what I'm going to do is run our server again.
We're gonna say Python managed a pie run server, and let's actually explore what is on the admin side
of things.
So enter there and it looks like we are running.
So let's head back to the browser.
OK, here I am.
Back at the browser I went to forward slash admin got rerouted to login.
Now I'm going to type in the username we created.
Jane underscore admin.
And now let's create the actual password.
In this case, I typed out Jane password.
Can I hit log in?
And if you successfully pass, then the correct username and password combo, then you should have created
the super user and you should see something like this.
You'll notice by default, there's only essentially authentication authorization under site administration.
So what you can do is you can view the site, you can actually change your password here, or you can
just log out.
We will talk about authentication authorization later on.
So there's actually a built in series of authentication authorization capabilities when jingo.
We can actually create groups which are made up of users.
And right now, we only have one user, which is kind of a super user and that user is me, Jane Admin
Jane Test.
There's no first name or last name right now.
Staff status.
That little checkmark essentially says, Hey, by the way, I'm staff here.
I can filter this automatically.
So notice just how amazing this is the fact that all this material was created for us by default.
Now, typically, what you also want to have here, depending on your website, are the models themselves.
So what I want to do is add in our car model and connect it to Django administration.
I'm going to do that in the very next lecture.