Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please refer to our video player troubleshooting guide for assistance.

Create the Django Superuser Account

The next step in building our app is to create our superuser account. Django comes with “batteries included” and one of those included batteries is an authentication system. Before we can take advantage of this useful feature, we have to set up an administrative account with full privileges. Django calls this the superuser account, and we can create it with a manage.py command, specifically createsuperuser.

00:00 Hi everyone! Welcome to video number eight in our series on making a location-based web app with Django and GeoDjango. The next step in building our app is to create our superuser account.

00:12 It’s often said that Django comes with batteries included, and one of these included batteries is an authentication system. Before we can take advantage of this very useful feature, we have to set up an administrative account with full privileges.

00:27 Django calls this the superuser account, and we can create it with a manage.py command, specifically createsuperuser.

00:35 So let’s do that now. This script is going to ask you for an account username and password, so have that in mind before you begin. Launch your terminal and at the prompt, type python manage.py createsuperuser.

00:49 You will be prompted for a username, then an email address.

00:55 I’m going to keep the email blank for now. For the password, I’m going to choose 123456789.

01:05 You’ll see that Django gives me a warning but I’m going to proceed anyway, since this is a learning exercise.

01:12 If you’re curious about the effect this had on our database, let’s take a look. In pgAdmin if we expand our shop tables, we see one called auth_user.

01:22 If we right-click it and View Data, we see that there’s a new record.

01:32 There’s my username, jackie, along with my hashed password.

01:38 Let’s log in with our new account. Go back to your editor for a moment and take a look at the project’s urls.py file. Remember I said this works as a sort of front desk for your site to route incoming requests.

01:51 There’s a route here configured as 'admin/'. Now open your terminal and type the manage.py runserver command to launch your site. When the site launches, click the localhost link to see your site in the browser.

02:07 Place your cursor in the address bar at the end of your localhost address and port, type /admin, and press Enter. This is the admin console provided by Django. Go ahead and log in.

02:22 You’re in! Now let’s select the Users link. What we find is a visual representation of what’s in our auth_user table. Pretty nice, right?

02:32 And we didn’t have to know HTML or CSS or build any of this. Wouldn’t it be nice, though, if we had a similar interface to manage our shop table data?

02:42 As you probably guessed, that’s what we’re going to do next. Join me in the next video, where we will not only add the shop table to our admin interface, but load the table with some initial data records using Django migrations.

02:54 See you there.

Become a Member to join the conversation.