Our next topic is to talk about login and logout. Now just in general, I have this GitHub repository called dj4e-samples and every once in a while you ought to see if I've found some bugs and fixed them. So go over to your samples and do a git pull. So every once in a while just do that. So Django, like in lots of situations, comes with a built-in login/logout system. There's lots of ways to do it. You can read up on it. It has a way to create users, has this nice admin interface, and so one of the things we like about Django is that we don't have to build some of these basic maintenance things. Add permissions and groups, we use this in the local library application, but we're not going to use that so much in our applications, and passwords, etc. And it has a way to store these things and various techniques. And so the first thing that you'll probably encounter when you're doing this is to create a superuser. And so you have to log in to your system, you create a superuser, give it a name, an email address. The email address is for password recovery, even though you can log in and you can create your superuser password anywhere, and then you do it. Now, there's a great xkcd cartoon for so many things. This is one guy says make me a sandwich and the other one says, what make it yourself, and then says, SUDO make me a sandwich, and the other person says, okay. So what SUDO means is it's a Linux command to switch to the superuser and do a command. So if you don't have permissions to do a command, you can say SUDO a command. And so that's what this xkcd. So that's what we call a superuser. That's the user that has all permissions, doesn't need to get any special permissions. This might be a good time to review what you're going to do when you wipe out your database. When you create that superuser, it just adds a row to a table in your db.sqlite, and you can wipe this out any time. That's why I like using SQLite for development in Django. If you remove it, you've removed all the tables, all of the tables created by migrations. The migrate command is what creates tables, the makemigration actually creates migrations, which are Python code. So if you're going to start fresh, you've got to remove the db.sqlite file. That's got rid of all your users, all your superusers, any data you've put in, it's gone. And then you have to wake it back up with a bunch of empty tables with a manage.py migrate and you'll see all those things. Lots of lines come out at that point, I didn't include them. And then you're going to have to create your superusers again. So just if you wipe your database, you've got to recreate your superusers. Once you have a superuser, the rest of the users are put in using the admin interface. You just go in and among all the other models that you might have in your application, the groups and the users are just models. They're models that happen to be built into Django and you don't have any responsibility for building them. And so, like I said, the groups and permissions is useful and you can read up on that and maybe your application needs to use those. But for me, I pretty much just make users and call it good. Later, we're going to learn how to use like social logins. So we'll use GitHub to log people in so you don't have to create any users other than your admin user. But in the short term, we're just going to use what are called local users which are stuck in the database, kept in the database, and easy to create, easy to maintain, but you tend to have to manually maintain them a little bit. So next we're going to look at, now that you've got a user, how do we, in our application code, log in and log out users. [MUSIC]