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

Corey Schafer · Beginner ·🛠️ AI Tools & Apps ·7y ago

Key Takeaways

This video tutorial demonstrates how to access and utilize the Django Admin Page for a full-featured web application, covering topics such as creating a super user, running database migrations, and managing users and permissions. The tutorial uses Django and Python as the primary tools, with manage.py being a crucial command-line utility for managing the project.

Full Transcript

hey there how's it going everybody in this video we'll be learning how to access the admin page of our Gengo site 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 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 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 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 run these migrations so again let me clear the screen so the first thing we can do here is to say Python managed to 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 super user command if we rerun that command now 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 testing three two one now obviously you'll want to make your password stronger in a real-world application okay so now we can see that 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 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 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 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 we can change our 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 create a new user so I'm going to create a new user 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 if we wanted to add an email address I could just say test user at company comm now let me scroll down here to 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 you

Original Description

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
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Corey Schafer · Corey Schafer · 0 of 60

← Previous Next →
1 Web fonts using CSS Font Face
Web fonts using CSS Font Face
Corey Schafer
2 Using Font Awesome in Desktop Applications (OS X)
Using Font Awesome in Desktop Applications (OS X)
Corey Schafer
3 Sublime Text 2: Setup, Package Control, and Settings
Sublime Text 2: Setup, Package Control, and Settings
Corey Schafer
4 ArcGIS API for JavaScript Part 1: Our First Web Map
ArcGIS API for JavaScript Part 1: Our First Web Map
Corey Schafer
5 Mac Tip: Windows' Snapping Feature on Mac with HyperDock
Mac Tip: Windows' Snapping Feature on Mac with HyperDock
Corey Schafer
6 Linux/Mac Terminal Tutorial: Creating Aliases for Commands
Linux/Mac Terminal Tutorial: Creating Aliases for Commands
Corey Schafer
7 ArcGIS API for JavaScript Part 2: Starting Templates
ArcGIS API for JavaScript Part 2: Starting Templates
Corey Schafer
8 Paver Patio Time Lapse
Paver Patio Time Lapse
Corey Schafer
9 Mac Tip: Ways to perform Screen Capturing and Screenshots
Mac Tip: Ways to perform Screen Capturing and Screenshots
Corey Schafer
10 WordPress Plugins: Imsanity
WordPress Plugins: Imsanity
Corey Schafer
11 WordPress Tips: Test your theme with Theme Unit Test and Monster Widget
WordPress Tips: Test your theme with Theme Unit Test and Monster Widget
Corey Schafer
12 Sublime Text 3: Setup, Package Control, and Settings
Sublime Text 3: Setup, Package Control, and Settings
Corey Schafer
13 Understanding Binary, Hexadecimal, Decimal (Base-10), and more
Understanding Binary, Hexadecimal, Decimal (Base-10), and more
Corey Schafer
14 Mac Tip: Adding Folder Stacks to the Dock
Mac Tip: Adding Folder Stacks to the Dock
Corey Schafer
15 CSS Tips and Tricks: Add External URLs to Print Stylesheets
CSS Tips and Tricks: Add External URLs to Print Stylesheets
Corey Schafer
16 JavaScript Arrays: Properties, Methods, and Manipulation (Part 7 of 7)
JavaScript Arrays: Properties, Methods, and Manipulation (Part 7 of 7)
Corey Schafer
17 JavaScript Arrays: Properties, Methods, and Manipulation (Part 1 of 7)
JavaScript Arrays: Properties, Methods, and Manipulation (Part 1 of 7)
Corey Schafer
18 JavaScript Arrays: Properties, Methods, and Manipulation (Part 5 of 7)
JavaScript Arrays: Properties, Methods, and Manipulation (Part 5 of 7)
Corey Schafer
19 JavaScript Arrays: Properties, Methods, and Manipulation (Part 4 of 7)
JavaScript Arrays: Properties, Methods, and Manipulation (Part 4 of 7)
Corey Schafer
20 JavaScript Arrays: Properties, Methods, and Manipulation (Part 3 of 7)
JavaScript Arrays: Properties, Methods, and Manipulation (Part 3 of 7)
Corey Schafer
21 JavaScript Arrays: Properties, Methods, and Manipulation (Part 2 of 7)
JavaScript Arrays: Properties, Methods, and Manipulation (Part 2 of 7)
Corey Schafer
22 JavaScript Arrays: Properties, Methods, and Manipulation (Part 6 of 7)
JavaScript Arrays: Properties, Methods, and Manipulation (Part 6 of 7)
Corey Schafer
23 Python Tutorial: if __name__ == '__main__'
Python Tutorial: if __name__ == '__main__'
Corey Schafer
24 Sublime Text Quick Tip: "Go To Definition" Click Shortcut
Sublime Text Quick Tip: "Go To Definition" Click Shortcut
Corey Schafer
25 How to quickly create favicons for the desktop, Apple/Android devices, tablets, and more
How to quickly create favicons for the desktop, Apple/Android devices, tablets, and more
Corey Schafer
26 Easily Resize Multiple Images Using Picasa
Easily Resize Multiple Images Using Picasa
Corey Schafer
27 Easily Resize Multiple Images Using the Mac Terminal
Easily Resize Multiple Images Using the Mac Terminal
Corey Schafer
28 Python Tutorial: virtualenv and why you should use virtual environments
Python Tutorial: virtualenv and why you should use virtual environments
Corey Schafer
29 Python Tutorial: pip - An in-depth look at the package management system
Python Tutorial: pip - An in-depth look at the package management system
Corey Schafer
30 Git Tutorial: Using the Stash Command
Git Tutorial: Using the Stash Command
Corey Schafer
31 How Software Engineers, Developers, and Designers can volunteer their skills
How Software Engineers, Developers, and Designers can volunteer their skills
Corey Schafer
32 Git Tutorial: Diff and Merge Tools
Git Tutorial: Diff and Merge Tools
Corey Schafer
33 Git Tutorial: Change DiffMerge Font-Size on Mac OSX
Git Tutorial: Change DiffMerge Font-Size on Mac OSX
Corey Schafer
34 Sublime Text Quick Tip: Launch Sublime Text from the Terminal
Sublime Text Quick Tip: Launch Sublime Text from the Terminal
Corey Schafer
35 Python Tutorial: str() vs repr()
Python Tutorial: str() vs repr()
Corey Schafer
36 Programming Terms: DRY (Don't Repeat Yourself)
Programming Terms: DRY (Don't Repeat Yourself)
Corey Schafer
37 Programming Terms: String Interpolation
Programming Terms: String Interpolation
Corey Schafer
38 Programming Terms: Idempotence
Programming Terms: Idempotence
Corey Schafer
39 Python Tutorial: Namedtuple - When and why should you use namedtuples?
Python Tutorial: Namedtuple - When and why should you use namedtuples?
Corey Schafer
40 Programming Terms: Mutable vs Immutable
Programming Terms: Mutable vs Immutable
Corey Schafer
41 Python Tutorial: Else Clauses on Loops
Python Tutorial: Else Clauses on Loops
Corey Schafer
42 Overview of Online Learning Resources
Overview of Online Learning Resources
Corey Schafer
43 Mac OS X Terminal Tutorial: Time-Saving Keyboard Shortcuts
Mac OS X Terminal Tutorial: Time-Saving Keyboard Shortcuts
Corey Schafer
44 Git Tutorial for Beginners: Command-Line Fundamentals
Git Tutorial for Beginners: Command-Line Fundamentals
Corey Schafer
45 Quickest and Easiest Way to Run a Local Web-Server
Quickest and Easiest Way to Run a Local Web-Server
Corey Schafer
46 Python Tutorial: Generators - How to use them and the benefits you receive
Python Tutorial: Generators - How to use them and the benefits you receive
Corey Schafer
47 Python Tutorial: Comprehensions - How they work and why you should be using them
Python Tutorial: Comprehensions - How they work and why you should be using them
Corey Schafer
48 Chrome Quick Tip: Quickly Bookmark Open Tabs for Later Viewing
Chrome Quick Tip: Quickly Bookmark Open Tabs for Later Viewing
Corey Schafer
49 Programming Terms: Combinations and Permutations
Programming Terms: Combinations and Permutations
Corey Schafer
50 Git Tutorial: Difference between "add -A", "add -u", "add .", and "add *"
Git Tutorial: Difference between "add -A", "add -u", "add .", and "add *"
Corey Schafer
51 Preparing for a Python Interview: 10 Things You Should Know
Preparing for a Python Interview: 10 Things You Should Know
Corey Schafer
52 SQL Tutorial for Beginners 1: Installing PostgreSQL and Creating Your First Database
SQL Tutorial for Beginners 1: Installing PostgreSQL and Creating Your First Database
Corey Schafer
53 SQL Tutorial for Beginners 2: Creating Your First Table
SQL Tutorial for Beginners 2: Creating Your First Table
Corey Schafer
54 SQL Tutorial for Beginners 3: INSERT - Adding Records to Your Database
SQL Tutorial for Beginners 3: INSERT - Adding Records to Your Database
Corey Schafer
55 Linux/Mac Terminal Tutorial: Navigating your Filesystem
Linux/Mac Terminal Tutorial: Navigating your Filesystem
Corey Schafer
56 Python: Ex Machina Easter Egg - Hidden Message within the Code
Python: Ex Machina Easter Egg - Hidden Message within the Code
Corey Schafer
57 Mac Tip: New Split Screen Feature in El Capitan
Mac Tip: New Split Screen Feature in El Capitan
Corey Schafer
58 Setting up a Python Development Environment in Eclipse
Setting up a Python Development Environment in Eclipse
Corey Schafer
59 Git Tutorial: Fixing Common Mistakes and Undoing Bad Commits
Git Tutorial: Fixing Common Mistakes and Undoing Bad Commits
Corey Schafer
60 SQL Tutorial for Beginners 4: SELECT - Retrieving Records from Your Database
SQL Tutorial for Beginners 4: SELECT - Retrieving Records from Your Database
Corey Schafer

This video tutorial teaches how to access and utilize the Django Admin Page for a full-featured web application. It covers creating a super user, running database migrations, and managing users and permissions. By following this tutorial, viewers can learn how to effectively manage their Django project's data and users.

Key Takeaways
  1. Run the command `python manage.py createsuperuser` to create a super user
  2. Run the command `python manage.py makemigrations` to detect changes and prepare Django to update the database
  3. Run the command `python manage.py migrate` to apply the migrations
  4. Run the server with `python manage.py runserver`
  5. Reload the admin page in the browser
💡 The Django Admin Page provides a convenient GUI for managing data and users, eliminating the need to implement backend functionality from scratch.

Related AI Lessons

Up next
Salesforce Flow New Features (Summer '26) | Open Record, URL & Show Toast Messages
AITECHONE
Watch →