Locked lesson.
About this lesson
Anytime you want to do something in Django, you need to create an app for it. In this lesson, we'll cover the steps how to create an app for your new project.
Exercise files
Download this lesson’s related exercise files.
StartApp.docx57.2 KB StartApp - Solution.docx
55.6 KB
Quick reference
StartApp
In this video we'll build out an app within our Django project.
When to use
Whenever you want to build a website with Django, you'll need to add at least one 'app' to your Django project.
Instructions
To add an app named 'resume' to our Django project, use the command:
python manage.py startapp resume
Hints & tips
- python manage.py startapp resume
- 00:04 Okay, in this video, we're going to start to build out our app.
- 00:07 So before we do that, I need to explain a quick concept with Django.
- 00:10 With Django, everything is an app, right?
- 00:14 So we've created a project, but we haven't created any apps.
- 00:18 And anytime you want to do something in Django, you create an app for it.
- 00:22 So we're going to build what's going to be a little personal resume website.
- 00:26 So we need to create a resume app within our Django project.
- 00:30 And for the most part, if your website's not that complicated,
- 00:33 you'll just build one app, and it'll be that website.
- 00:36 But if you want to add different things to your website later on,
- 00:39 like a message board or a tech support center or something like that,
- 00:43 you'll likely create a separate app for each of those things.
- 00:46 Now those are advanced topics, we're not really going to deal with that in this
- 00:50 course, we're just going to build one simple app, one simple website, but
- 00:54 just sort of getting in the habit of thinking of things in Django as apps.
- 00:59 So we need to create our first app, and
- 01:01 that's what we're going to do in this video.
- 01:03 So head back over to our terminal.
- 01:05 And I'm going to clear the screen here.
- 01:08 So to create an app, we just type in python manage.py.
- 01:11 Remember, almost always python manage.py, and the command we want is startapp,
- 01:16 and then we need to name our new app, and let's just call it resume.
- 01:20 You can really call it anything you want, and boom, it's done.
- 01:25 So now we can head back over to our Sublime text editor, and we see, boom,
- 01:29 this new resume directory popped right up.
- 01:31 And we didn't have to do anything to Sublime, it just popped up automatically,
- 01:36 and we're good to go.
- 01:37 So we still have our original Django website folder, and
- 01:41 it still has those same files that were in it.
- 01:44 Now we just have this new resume folder with a bunch of stuff in it.
- 01:47 And you'll notice there's a lot more stuff in this folder
- 01:52 than there were in our original Django website directory.
- 01:57 And that's because for the most part from here on out,
- 02:00 we're going to be working in this resume folder.
- 02:03 We're going to be building out our resume website, so
- 02:05 the things that we're going to be doing are inside this directory.
- 02:09 So you can see there's a views.py file.
- 02:11 It's basically empty right now.
- 02:12 There's tests, we won't be talking about that in this course.
- 02:16 There's models, models are another word for database.
- 02:20 So we're not going to be doing any database stuff in this course, so
- 02:23 we can ignore that.
- 02:24 Apps.py, admin.py, we'll talk about this, it has to do with the administration area,
- 02:30 which is again a database thing, and we're not going to be dealing with database
- 02:34 stuff in this course, so we can ignore that.
- 02:36 And this init.py file and you'll notice that it's completely empty.
- 02:40 And if we look at our Django website,
- 02:43 it had an init.py file as well that was also empty.
- 02:46 That's just a Django thing.
- 02:47 Most directories that are created using Django in Django come with
- 02:51 an empty init.py file, you can just sort of ignore that.
- 02:55 So this is the structure we're going to be dealing with throughout the rest of
- 03:00 the course.
- 03:01 And like I said, we're going to be mostly dealing with this resume directory.
- 03:05 Now we've got pretty much all of the framework done.
- 03:08 We've got all the tools that we're going to need.
- 03:09 We've installed everything.
- 03:11 We've created our project, we've created an app within the project.
- 03:16 We've migrated the server, we've migrated the database, and
- 03:20 now we can actually start to build out our actual website and
- 03:24 make it look better than this basic little rocket page that we have so far.
- 03:30 So in the next video, we'll look at Django views,
- 03:34 which are basically web pages and that'll be in the next video.
- 03:40 [BLANK AUDIO]
Lesson notes are only available for subscribers.