Previous Lesson: Lesson 4: Install Django

We are going to build projects. And to get organized with our computer, we need a place, directory, or folder where we can put all these projects. So in this lesson, we’ll start a new project in Django.

We’ll first learn some Terminal commands to get anywhere in our Terminal.

Create a new folder

If you are using Windows, go to your Windows Explorer. If you are using Mac, go to your Finder. Now select your home directory, in my case, that would be zedd:

Right Click on your mouse:

Select New Folder:

Next, name your folder Projects. But because I already have that directory, I’ll name this Other Projects:

ENTER:

Good.

Terminal Commands

I am currently using Mac.
Note: Some commands on my Terminal may not be appropriate for your computer, especially if you’re using a different operating system like Windows or Linux.

cd

cd is short for “change directory”. “Directory” here just means “folder”. So in other words, we are going to “change folder”.

This image has an empty alt attribute; its file name is Screen-Shot-2020-02-20-at-6.33.21-PM-1024x589.png

Above, you’ll see that I’m inside the Learn Python (course) folder, that’s why it’s indicated there. The zedd is the home directory. Meaning, it is the parent of the Learn Python (course) folder. What command will you do to get back to your home directory?

cd /

Notice that it has a SPACE before the slash (/), especially if you’re using Mac. On Windows, this could be just like cd/. Let’s try it:

Hit ENTER:

Nice, now we’re on our home directory.

cd ~

(You can delete your Terminal by clicking on that ‘trash can’ icon, and create a new one by clicking on that +.) We can also use this to get back to our home directory:

ENTER:

Alright!

cd (only)

This is the easiest way to get back to your home directory. I’m sorry that I made this last. I just want you to know that you have many options:

Press ENTER:

Nice. What if we wanted to see all the different folders inside a directory?

dir or ls

If you’re using Windows, use dir. If you’re using Mac or Linux, use ls. The dir means “directory”; ls means “listing directory”. Let’s try it:

Hit ENTER:

Now we can see all the folders, or directories, inside our home directory.
Note: It is important to remember that this is my computer, so the files or directories that you will see here may not be (and will not be) on your computer.

Now that you see all your folders, choose where you would want to put your project. You remember the folder that we’ve created earlier? We want to go inside that folder, but how?

cd (then directory name)

We’ll use cd again because we are going to change directory. But this time, do this:

While you’re not yet finished typing your directory name, I want you to press TAB:

You’ll notice that it autofills the rest of the name for us. Also, it is important to remember that when going inside a directory that has a space in between, we should add a slash (\) after the first word. ENTER:

Yay! We’re now inside our project folder! But what if accidentally, we’ve gone inside a different folder? How do we go back?

cd . .

(There’s a space before the dots). Use this:

Then ENTER:

Now we’re back to our home directory. Let’s go back to our project directory:

TAB:

ENTER:

Very good! Now you have just acquired a new skill in commanding your Terminal! Now what?

django-admin

Now let’s start a new project in Django. Type django-admin and remember to type this exactly:

Hit ENTER:

Waoh! That’s a lot! Don’t worry, we’re not going to discuss all of them. Instead, we just need that startproject. Now I want you to hit the UP Arrow in your keyboard and that would get our previous command (which is the django-admin):

And then add startproject. Don’t press ENTER yet once you’re done typing this!

Good. We need to give our new folder a name. Let’s name it wordcount:

Note: The wordcount has to be one word. Although, you can put dashes () or underscores (_) between these two words if you want.
ENTER:

“It didn’t do anything.” Is that really the case?

New directory!

Open your Finder or Windows Explorer and go to your project folder:

Success! We start a new project in Django! When you try opening this new directory:

What is this? Let’s talk about that in the next lesson because this lesson has been a little lengthy. If you had any problems with starting a new project in Django, please let me know on the Comments section below. And I’ll do my best to help you with that.

Next Lesson: Lesson 6: Running Our Django Server

3 Replies to “Lesson 5: Start a New Project in Django”

Leave a Reply

Your email address will not be published.