# Python Django Tutorial: Full-Featured Web App Part 4 - Admin Page

## Метаданные

- **Канал:** Corey Schafer
- **YouTube:** https://www.youtube.com/watch?v=1PkNiYlkkjo
- **Дата:** 31.08.2018
- **Длительность:** 8:59
- **Просмотры:** 446,997

## Описание

In this Python Django Tutorial, we will be learning how to access the Django Admin Page for our application. The Administration Page is a great way to see what data is currently in our application, and also gives us a nice GUI for creating or modifying that data. Let's get started...

The code for this series can be found at:
https://github.com/CoreyMSchafer/code_snippets/tree/master/Django_Blog


✅ Support My Channel Through Patreon:
https://www.patreon.com/coreyms

✅ Become a Channel Member:
https://www.youtube.com/channel/UCCezIgC97PvUuR4_gbFUs5g/join

✅ One-Time Contribution Through PayPal:
https://goo.gl/649HFY

✅ Cryptocurrency Donations:
Bitcoin Wallet - 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet - 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet - MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot

✅ Corey's Public Amazon Wishlist
http://a.co/inIyro1

✅ Equipment I Use and Books I Recommend:
https://www.amazon.com/shop/coreyschafer

▶️ You Can Find Me On:
My Website - http://coreyms.com/
My Second Channel - https://www.youtube.com/c/coreymschafer
Facebook - https://www.facebook.com/CoreyMSchafer
Twitter - https://twitter.com/CoreyMSchafer
Instagram - https://www.instagram.com/coreymschafer/

#Python #Django

## Содержание

### [0:00](https://www.youtube.com/watch?v=1PkNiYlkkjo) <Untitled Chapter 1>

hey there how's it going everybody in this video we'll be learning how to access the admin page of our Gengo site

### [0:05](https://www.youtube.com/watch?v=1PkNiYlkkjo&t=5s) Admin Page

now the admin page is a great way to see what data is on your site it also gives you a nice GUI for creating updating or deleting that data now we saw this admin login page earlier in the series but we didn't do anything with it so just to remind you what it looked like let's start up our development server which I already have running from the command line and now let's open up our page so I've got the home page here ok so within our home page let's navigate to forge slash admin like we saw earlier and we can see that we get this admin login now we can't login here yet because there are no default usernames or passwords or anything like that we actually have to

### [0:45](https://www.youtube.com/watch?v=1PkNiYlkkjo&t=45s) Create an Admin User

create an admin user so that we can log in here for the first time so let's bring back up our command line and I will stop the development server and now let me clear the screen here so that we have some room and now the command to

### [0:58](https://www.youtube.com/watch?v=1PkNiYlkkjo&t=58s) Create a New User for a Super User To Login to that Admin Page

create a new user for a super user to login to that admin page we can say Python manage py and this is create super user all one command now if we were to run this right now then it's not going to work so let me run this and show you why it isn't going to work right now so I ran that and we got a lot of error feedback here but the very last line of this error gives us a good hint it says operational error no such table off user so the problem here is that we haven't created the database that we'll be using for this project yet but that's very easy to do all we have to do is run a few migration commands now database

### [1:37](https://www.youtube.com/watch?v=1PkNiYlkkjo&t=97s) Database Migration

migration is something that we'll talk about more throughout the series but basically it allows us to apply changes to a database now since we haven't created a database yet this first migration will create the database and add a bunch of default tables for us and this auth table here is one of those tables that is going to get created and then it will allow us to run that create super user command so let's go ahead and

### [2:04](https://www.youtube.com/watch?v=1PkNiYlkkjo&t=124s) Migrations

run these migrations so again let me clear the screen so the first thing we can do here is to say Python managed to

### [2:11](https://www.youtube.com/watch?v=1PkNiYlkkjo&t=131s) Make Migrations

I make migrations so let's run that and when we run that it tells us that there were no changes detected and now if we had created some of our own database tables or models then we would have seen some changes there but we'll see that in the next video when we actually work with the database so make migrations just detects the changes and prepares Django to update the database but it doesn't actually run those changes yet in order to apply the migrations we need to say python managed dot P Y and then migrate so if we run that then we can see that ran through some migrations and those all came back as ok so that auth user table should now exist so now if I rerun that command that we tried earlier so let me clear the screen and hit up a couple of times to find that create

### [3:03](https://www.youtube.com/watch?v=1PkNiYlkkjo&t=183s) Create Super User

super user command if we rerun that command now it seems to be working and it's asking us for a username so I'm going to enter a user name of Corrie m/s and an email address I'll just put in Cori M Schaefer at gmail. com and now for a password I'm just going to do testing three two one and again now obviously you'll want to make your password stronger in a real-world application okay so now we can see that super user was created successfully so now let's run our server again and reload that admin page in our browser so we'll do Python manage py run server and once that is running we can go back to our browser here and reload the login page for the admin and now we should be able to sign in with that username and password that we used to create the super user so for me that was Corey MS and I used a password of testing three two one so let's try to login with that and we can see that now we logged in successfully okay so this is the default

### [4:12](https://www.youtube.com/watch?v=1PkNiYlkkjo&t=252s) The Default Admin Page for the Django

admin page for the Django site so let me make this a little larger here so that you can see everything now this is one great thing about Django is that it comes with this really awesome admin site by default so this allows us to do a lot to work on the backend that would take a ton of effort to implement if we were to do this from scratch on our own so let's take a quick look around so we can see that we have groups and users here now if I click on groups then it says that we have zero groups right now so we could add some if we want but I'm not going to right now if we look towards the top then we can see that we have some breadcrumbs here that show us exactly where we are on the admin page so right now we are within authentication and authorization and within groups so to go back a level I can just click up one level here and now we're back to the page that we were at before so now let's click on users and we have one user here right now and it's the one that we just created so if I click on that user then it takes us to a page with a lot more details where we can add more stuff or change some things that we've already added so we can see we have our user name here of Cory M s now for our password we set our password to testing three two one but now we have this big long hashed password so it never even stores our raw password so Django handled the hashing of that password for us and does all of the proper checks when we log in order to see if our entered password gets hashed to that correct value so that's a lot of added security there that we just get for free so that's awesome so moving down here we can see that we have a first name last name we can change our email address permissions and all kinds of stuff but I'm not going to change anything in here right now I just wanted you all to see what all was possible so let's go back to the top and click on the breadcrumb that takes us back to our list of users and now on the top right here let's click on add user so now we can actually

### [6:19](https://www.youtube.com/watch?v=1PkNiYlkkjo&t=379s) Create a New User

create a new user so I'm going to here so I'll do test user and for the password I'll do just the same thing testing three two one and we need to confirm this user is password and now let's click on save and continue editing and we could continue adding fields for this you here if we wanted to so for example add an email address I could just say test user at company comm now let me scroll down here to

### [6:49](https://www.youtube.com/watch?v=1PkNiYlkkjo&t=409s) Permissions

permissions so that we can see what permissions it gave this new user so we can see that it created this as an active user but it didn't give this person staff status by default and it also didn't give them super user status by default now staff status means that this person would be able to log into the admin site and super user status means that they would have all of the permissions so you know to delete other users and things like that now if we scroll all the way to the bottom here then we can see that we can also delete this new user but I'm going to go ahead and leave him here so let's go ahead and save that email change that we made and then go back to our main page now one less thing I'd like to point out over here to the right is that it also shows us our latest changes so we can see here that we have a plus sign next to the user which means that we created that user so that's a great way of to keep track of what's going on and we can see that we have a pencil icon here next to the test user and that is where we edited the user and added their email address okay so I think that is going to do it for this video so in this video we just got a quick look at the admin page for Django but we're going to be using this page a lot throughout the series now in the next video we'll be learning how to work with databases so that we can get started with creating some real data for our website instead of using the dummy data that we have for now and we're also going to learn how to get that data added to this admin page so that we can come in here and create update and delete posts right from here within the admin page but if anyone has any questions about what we covered in this video then feel free to ask in the comment section below and I'll do my best to answer those and if you enjoyed these tutorials and would like to support them there are several ways you can do that these ways to simply like the video and give it a thumbs up and also it's a huge help to share these videos with anyone who you think would find them useful and if you have the means you can contribute through patreon and there's a link to that page in the description section below be sure to subscribe for future videos and thank you all for watching you

---
*Источник: https://ekstraktznaniy.ru/video/12170*