Setting Up a Project in the Current Directory
00:00 In this lesson, you will learn about an alternative for setting up a Django project, which is very similar but there’s going to be a tiny change that makes your directory structure a little different.
The tiny change is literally just adding a dot (
.) at the end of the command. Before, you ran the command
django-admin startproject, gave the project name—in our case, this was
setup—and that was it, but now if you were to add a dot at the end, just a tiny dot, this is going to create a different directory structure.
But let’s take a step back and just think about what does this dot actually mean. So by now, in this course alone, you’ve encountered the dot twice. The first time, just now, you saw it when running
django-admin startproject <projectname> and then the dot to create a different directory structure, slightly.
01:19 Now, not to be too confusing, this dot here means something else—this denotes a hidden directory—but this dot with the slash is the same as this dot. In Unix systems, this just means it refers to the current directory.
So here, you’re saying inside of the current directory—and you see it by ending with this slash—you want to create a new folder called
.venv. And same in this
01:51 you use the dot to denote the current directory with which you’re saying “Use the directory you’re already in as the Django project folder.” So you could also add a slash here at the end just to kind of, like, signify that this is actually a directory that you’re talking about, but you don’t have to put the slash and it makes it kind of… Usually, if you see it online, you won’t see it. All right, so this is what the dot does.
It denotes the current directory. Now let’s actually run the command and see the difference in the folder structure that it creates. Back over here in VS Code—and we still have this
setup/ folder, this structure that you created before—I will remove this just to show you the difference.
When I execute this command, you can see something similar happened to before, you got a
setup/ folder, but you will notice that the
manage.py file now actually sits directly in your current working directory. And the
setup/ folder is the management app.
So when running
django-admin startproject setup . with a dot, then what gets created is the management app—this is the red square in the graphic that you saw before—and then the
manage.py command center of your app, and they get created directly inside of your current working directory, rather than for Django to create a new project folder of the same name as your management app.
So now you learned two different ways of starting your Django project. You can do it either with
django-admin startproject and then your project name, or if you want to skip the creation of the project folder, then you use the same command but you add a dot (
.) at the end.
Become a Member to join the conversation.