Locked lesson.
About this lesson
In this lesson, we'll walk through the steps to create a new project and add it to Sublime Text Editor.
Exercise files
Download this lesson’s related exercise files.
Create A New Project And Add Project To Sublime (Walkthru).docx57.2 KB Create A New Project And Add Project To Sublime (Walkthru) - Solution.docx
55.7 KB
Quick reference
Create A New Project And Add Project To Sublime (Walkthru)
In this video we'll start a new Django Project called djangowebsite and open that project in Sublime Text.
When to use
You'll do this once for each project you create.
Instructions
To create a new project in Django called djangowebsite, use the command:
django-admin.py startproject djangowebsite
Then open the project in Sublime text by clicking:
Project > Add Folder To Project
...from the top menu in Sublime, and then navigating to the /c/mywebsite/djangowebsite directory.
Hints & tips
- django-admin.py startproject djangowebsite
- 00:04 Okay, so we've installed our virtual environment.
- 00:06 We've installed Django.
- 00:07 Now it's time to create our project.
- 00:09 So I'm going to go ahead and clear the screen and make sure we're in C/mywebsite.
- 00:15 Make sure our virtual environment has been turned on.
- 00:17 And to create a Django project we just type in django-admin.py startproject,
- 00:23 all one word, and then we just need to name our project.
- 00:27 So let's just call this djangowebsite, okay?
- 00:35 Now if we type in ls to list the stuff that's in this directory.
- 00:39 Notice we still have our virtual environment directory that we created
- 00:42 a couple of videos ago.
- 00:43 But now we have this djangowebsite directory.
- 00:46 So this is where our actual project is going to sit from now on,
- 00:49 inside this directory, so we need to change into that directory.
- 00:53 We need to use the cd command, change directory and
- 00:56 then just type in djangowebsite.
- 00:58 Now I just started to type dj and then I hit the Tab key on my keyboard,
- 01:03 and that auto corrected and typed out the whole thing for me.
- 01:07 It's just sort of a shortcut.
- 01:08 So go ahead and hit Enter.
- 01:12 And you can see now we're in C/mywebsite/djangowebsite.
- 01:16 And if we type in ls to list the stuff in this directory,
- 01:19 we see a couple of different things.
- 01:21 But the main thing we want to see is this manage.py file.
- 01:25 We'll talk about this later.
- 01:26 But the manage.py file is probably one of the most important files in Django.
- 01:31 We're going to use it for a lot of things, and it's a good rule of thumb when you're
- 01:36 in your terminal, you always want to be in the directory that has the manage.py file.
- 01:41 So if you're not really sure, if you can't really remember if you're supposed to
- 01:46 be in this directory, or this directory, just give a quick ls command and
- 01:50 see if the manage.py file appears.
- 01:52 If it does, you're in the right place.
- 01:54 So okay, we've got our project, it's been created.
- 01:57 Now we want to pull this up in sublime so that we can start actually writing code.
- 02:01 So fire up your Sublime Text Editor and come over here to Project and
- 02:06 click on it, and then come down here to Add Folder to Project.
- 02:10 And this box pops up, you just want to go down to your local disk,
- 02:15 your C drive, and then just navigate to the folder we've just created.
- 02:19 So it was my website and then djangowebsite.
- 02:23 Now click it once just to highlight it and then click Select Folder.
- 02:27 And when you do, boom, it pops up here and you can see here's our manage.py file that
- 02:31 we saw earlier and here's this djangowebsite directory.
- 02:35 And when we click this to expand it,
- 02:37 you can see there's all kinds of stuff inside of here.
- 02:39 So this is the setup we're going to be using for
- 02:42 throughout the rest of the course.
- 02:43 We're going to be working in Sublime Text from time to time.
- 02:46 We'll issue commands in our terminal.
- 02:49 But for the most part, we're going to be working inside this text editor.
- 02:53 So this is the sort of the main setup,
- 02:55 you'll you'll get used to seeing all these things.
- 02:58 And a lot of these files compared to some other web frameworks,
- 03:01 there's not a lot going on here.
- 03:02 There's not a lot of files, but there's still a few and
- 03:05 it might be a little confusing looking, but it's super simple.
- 03:09 We're not going to use most of these and
- 03:10 we'll start to talk about them in the next couple of videos.
- 03:13 But, very cool.
- 03:14 Now, in order to open any of these files all you have to do is click it.
- 03:19 And when you do it pops up close the file again, you'll just click this little x.
- 03:24 You can open several of.
- 03:26 Have them at the same time.
- 03:27 And very cool.
- 03:28 So that's all for this video.
- 03:29 In the next video, we'll go ahead and run the Django server and fire up our project
- 03:34 in a web browser to actually see if it was created successfully.
- 03:37 And that'll be in the next video.
Lesson notes are only available for subscribers.