Setting Up a Django Project
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.
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.
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.
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.
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.
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.
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.
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.