Admin - Django Web Development with Python 9
Key Takeaways
Django admin site configuration and blog post management using Python and Django framework
Full Transcript
What is going on everybody? Welcome to another Django with Python for web development tutorial. In this tutorial, what we're going to be talking about is the admin app that comes with your Django applications. So uh the first thing we need to do if we want to utilize the admin is um as you'll see if we go to our website okay and you want to go to admin you just do slashadmin and you get here and then you start thinking hm uh what do I do now admin right so you don't have an admin you don't know what the login is so the first thing you have to do is actually create a super user or an admin so that's what we're going to do first so we're going to go and break the running server and we'll go up here and get manage.py. And what we want to do is python manage.py create super user. Hit enter. And then now you can define the user. I'll just call mine admin. Email address uh hskinsleyhmail.com. Password whatever you want it to be. I think I picked a pretty pretty good one. Okay, got our user and I need to log in before I forget the password. So, we'll come over here and the username will be admin. Oh, wait, hold on. We need to uh run the server. Create super user. So, manage.py run server. Uh, and now what we want to do is log in. So you'll go, you know, your your website/admin password. [Music] Good. Okay. So once you've done that, you log in. This is the Django administration. So you'll see here that you've got uh groups and you've got users in here. Uh and then what you could do is, you know, you can click on groups for example there. We don't have any groups, but you could like plus add a group and do fancy stuff here. And you can go into users and look at that. There we are. And we could set um you know are we an active user. If you uncheck this, it's basically the equivalent of deleting an account. It doesn't delete the account, but it doesn't let them log in. Staff status, super user status. You can create custom groups and give very specific custom user uh permissions. What can they this user actually do? You've got all this stuff. Blah blah blah. Okay, cool. But we don't really care that much about that. What we really want is well, we want a pony, right? We want to be able to access our blog table basically here uh and edit the blog, post blogs, do everything via this administration panel, okay? Because we want a pony. So, what we're going to do is uh first we have to admit that we're not going to get a pony, but Django is going to give us something close to a pony. So, what we're going to do is we're going to go into blog and you should already have an admin.py file. Go ahead and open that up. And you'll see that we're importing some stuff naturally. And then you can register your models here. So what we're going to do is from blog.models import posts. So that's our post class which defines that table and all that fun stuff. Now what we're going to do is simple admin.register register and we register post. Save that. Come back to your admin panel. Go back to the home. Boom. There's post. Oh my goodness. So now you can see that we got add and change. And we can also click, but there's zero post. But then we can also add a post here. So let's go ahead and add a post. Hermager Django is awesome. Wow. Wow. Wow. Wow. Wow. Okay. And then for date, what's cool is you can very quickly just say today right now. And uh save and add another. Let's say is today really December. Oh my goodness, it's December. Anyway, probably by the time anybody's seeing this, it'll be even later. Anyway, uh save. And you can either save and continue editing. You can save and add another. Or you could just save. And we'll save and add another. And um then we'll say amazing grace today and now. Save and add another uh hello world. Good. Hia. And then we'll do today and now. But you can also do like this like you could say uh this post was back in September. Okay. Save. All right. So now these are our admin, blog, and posts. So let's go back home. And you would like if you just logged in admin, you'd see this. You could click on post, see like, okay, cool. Here's all our posts. Hello world and blah blah blah. And you could edit it. You could delete it. You could save and continue editing and save and add another. Cool. So now, what if we just go to our homepage and we click on blog. There's our information, right? It's just there. And sure enough, the titles are links. And in our excitement, we click on one and ah, it doesn't work. Why doesn't it work, you ask? Well, of course, we don't have any URL path that explains uh or works with slashblog/2. We can even see, well, at least here's slashblog, but this is the homepage, right? It required it to be slashblog, not slashblog 2. So, now what we have to do is create uh the handling. We need the URLs. We need a view um for the individual posts. So, um that's what we're going to be covering in the next tutorial. This one should be quick and easy. Quick and painless, easy enough for you guys to get up to this point. But if you had any problems, uh feel free to leave them below. One thing to keep in mind, if this is the first time you visited the admin, which if you're following along, it probably was. If it didn't work for whatever reason, you can always go to my site, go to settings, and make sure admin is installed. So you'd come down here, make sure that you have this line. It should be there by default. Um, but if it's not there for whatever reason, you might need to add that part. Okay, so uh that's that. As always, thanks for watching. Thanks for all the support, subscriptions, and until next time.
Original Description
In this 9th Django web development with Python tutorial, we're going to cover the admin page, along with adding some blog posts to our application. Just when you thought you've seen most of the backend magic that Django has to offer, there's more! The Django admin site/app is pretty incredible. This is your Admin Control Panel, and it's already done. Just like Django handles your database work with the models.py, your Admin page is going to work very much in the same way. To access the admin page, you visit /admin/, assuming the admin app is indeed installed.
Sample code and text-based tutorial: https://pythonprogramming.net/admin-django-python-tutorial/
https://pythonprogramming.net
https://twitter.com/sentdex
https://www.facebook.com/pythonprogramming.net/
https://plus.google.com/+sentdex
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from sentdex · sentdex · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Matplotlib Python Tutorial Part 1: Basics and your first Graph!
sentdex
Python Encryption Tutorial with PyCrypto
sentdex
Python's Logging Function
sentdex
wxPython Tutorials 1: Making Windows GUIs with Python : Installing + 1st window!
sentdex
wxPython Tutorials 2: Making Windows GUIs with Python: Customizing Window Parameters
sentdex
wxPython Programming Tutorial 3: Menu Bar and Menu Button
sentdex
wxPython Programming Tutorial 4: Panels
sentdex
wxPython Programming Tutorial 5: User Input Saved To Variables
sentdex
wxPython Programming Tutorial 6: Multiple Choice Input
sentdex
wxPython Programming Tutorial 7: Adding Static Text and Colors
sentdex
wxPython Programming Tutorial 8: Custom Button Images
sentdex
wxPython Programming Tutorial 9: Tool Bar Items and Sub Menus!
sentdex
Basic PHP Tutorial 13: Multi-dimensional Array
sentdex
Basic PHP Tutorial 15: Functions and Global Variables
sentdex
Basic PHP Tutorial 12: Associative Array
sentdex
Basic PHP Tutorial 14: Foreach loop
sentdex
Basic PHP Tutorial 16: Include and Require
sentdex
Basic PHP Tutorial 7: Assignment, comparison and Logical operators
sentdex
Basic PHP Tutorial 4: Variables and Comments
sentdex
Basic PHP Tutorial 11: Arrays part 1, basic array
sentdex
Basic PHP Tutorial 6: If else and else if conditionals cont'd
sentdex
Basic PHP Tutorial 1: Intro to PHP
sentdex
Basic PHP Tutorial 3: HTML with PHP
sentdex
Basic PHP Tutorial 9: While Loop
sentdex
Basic PHP Tutorial 10: Switch Statement
sentdex
Basic PHP Tutorial 2: Print and Echo
sentdex
Basic PHP Tutorial 5: If else and else if conditional statements
sentdex
Basic PHP Tutorial 8: Arithmatic Operators: Doing math with php
sentdex
Basic PHP Tutorial 17: User Input Form Example / String Manipulation
sentdex
Basic PHP Tutorial 18: HTML Entities and forms cont'd
sentdex
Basic PHP Tutorial 19: Finding words in strings
sentdex
Basic PHP Programming Tutorial 20: Saving to a File / writing and appending
sentdex
Basic PHP Programming Tutorial 22: Hashing part 2: salting
sentdex
Basic PHP Programming Tutorial 23: Variables in Strings and tokenizing
sentdex
Basic PHP Programming Tutorial 21: MD5 Hashing For Security
sentdex
Basic PHP Programming Tutorial 24: String similarity
sentdex
Basic PHP Programming Tutorial 25: Time and Time stamps
sentdex
Basic PHP Programming Tutorial 26: Die and Exit
sentdex
Basic PHP Programming Tutorial 27: MySQL Databases Part 1
sentdex
Basic PHP Programming Tutorial 28: MySQL Database Part 2: Reading From Database
sentdex
Basic PHP Programming Tutorial 29: MySQL Database Part 3: Inputting Data
sentdex
Basic PHP Programming Tutorial 30: MySQL database in Use
sentdex
Django Tutorial Web Development with Python Part 1: Installing Django
sentdex
Python Tutorial: File Deletion and Folder Deletion / directory deletion
sentdex
Python Tutorial: How to Rename Files and Move Files with Python
sentdex
3D Graphs in Matplotlib for Python: Basic 3D Line
sentdex
3D Plotting in Matplotlib for Python: 3D Scatter Plot
sentdex
3D Charts in Matplotlib for Python: Multiple datasets scatter plot
sentdex
Sikuli Tutorial 1: Visually programming in python!
sentdex
Sikuli Tutorial 2: Program visually in python!
sentdex
Sikuli Tutorial 3: Program visually in python!
sentdex
3D Bar Charts in Python and Matplotlib
sentdex
3D Plane wire frame Graph Chart in Python
sentdex
Raspberry Pi Part 1 Introduction
sentdex
Raspberry Pi Part 8: First Download and Update! (Firmware)
sentdex
Raspberry Pi Part 10: How to set up a Linux Web Server on your Pi
sentdex
Raspberry Pi Part 11: Remote Desktop
sentdex
Twitter Analysis: How to rank a user's influence
sentdex
GPIO Tutorial for Pi Part 2 - Programming the GPIO
sentdex
GPIO Tutorial for Raspberry Pi Part 1 - Setting up
sentdex
Related AI Lessons
⚡
⚡
⚡
⚡
Common Next.js Errors (and How I Solved Them)
Dev.to · gary killen
Applying Scalability in Backend (CodeBuddy)
Medium · LLM
Why Every Backend Developer Should Learn Nginx Before Going to Production
Medium · DevOps
Connecting Frontend to Backend: A Backend Engineer’s Reality Check
Medium · Programming
🎓
Tutor Explanation
DeepCamp AI