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

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds 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 the default subtitles language 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 see our video player troubleshooting guide to resolve the issue.

Setting Up a Django Project

Give Feedback

00:00 In this lesson, you will finally start working with the Django package that you installed in the previous lesson and you will use it to set up a Django project. Before you do that practically, let’s take a little detour and just talk about the difference between Django projects and Django apps, because these are two specific terms that have a meaning for Django and it’s good to have an overview understanding of what each of them are.

00:25 So, a Django project is a larger-scale structure. A Django project can contain multiple apps and generally when you set up a Django project, you get this larger-level structure plus a management app.

00:39 The management app is a Django app, but it is a special one in that case, so any other app that you will set up following this one is going to be a bit different, but they’re going to be the same to each other.

00:51 But what you are going to do in this lesson is set up a Django project, which means this larger-level structure plus the management app. And the command for doing this is django-admin startproject and then you give it a name—a name that you want your project to have. For this example, I will call the project setup, so my command will be django-admin startproject setup.

01:17 Let’s head over to VS Code and do that practically and see what happens.

01:23 Over here with my activated virtual environment, I’m ready to start a Django project by typing django-admin startproject, and then give it a name, and I said it’s going to be setup for here. So once I type this, I can press Enter and let Django do its thing. It’s already done.

01:45 You can see a new folder pop up here in the folder structure. And this is the project folder, so you can think of it as the black square. It contains a couple of things.

01:55 It contains another folder of the same name and then a file called manage.py. Let’s look at this in a schema, what happened here.

02:05 So, running the command django-admin startproject setup gave us this structure here. So that was the folder that I was in when running the command, and it created a folder called setup/ with some other stuff in there.

02:21 Let’s actually walk over the most important things step-by-step, but keep in mind that what you created here now is this black square with the management app inside of it. So setup/ is the black square and the nested setup/ is the red management app.

02:39 And just to drive the point home, let’s look at this step-by-step. So, you’re inside of the current folder, you ran a command, you get one folder in there called setup/.

02:48 This is your project folder for your Django project and it then contains another folder of the same name—in this case, it’s called setup/ because that’s the project name you gave, so setup/setup/. That’s down here, this is your management app for your Django project and it contains a couple of files that you can check out.

03:09 And then, finally, it also contains a Python file called manage.py, which is the command center of your app and you will use this file quite often when you interact on a project level—for example, when you do some tasks involving the database or if you want to create a superuser, then this is where the commands for this live and this is part of your Django project.

03:33 All right! So, you might wonder “Why do you have this double?” Like, why do we have setup/ and then another setup/ in here and isn’t that kind of, like, superfluous? And there are ways of skipping one level of these directories by just essentially declaring the current folder that you’re in as your Django project folder. And in the next lesson, I will show you how to do that.

Become a Member to join the conversation.