Building data-driven web apps with Flask and SQLAlchemy Transcripts
Chapter: Jinja2 templates
Lecture: Project structure with shared layout

Login or purchase this course to watch this video and the rest of the course contents.
0:00 In this last section we talked a bit about
0:02 organizing our templates folder
0:03 and grouping those by where their related views lived.
0:08 We're not quite far enough along in our
0:11 creation of our site to really see that manifest.
0:13 So let me show you. Let me walk you through
0:15 what this is going to look like at the end
0:17 so you can appreciate it a little bit better.
0:19 Over here is what our site's going to look like at the end.
0:23 Notice we have our views folder.
0:25 This is where our html view methods live.
0:29 So in the account when we have stuff
0:32 to do with account and home
0:33 we have like the home and about and packages.
0:35 It'll be like details and popular and so on.
0:37 We're going to organize all of our related templates
0:40 by their view that they come from.
0:42 So over here we're going to say
0:43 all the stuff to do with packages
0:45 is going to be in a sub-folder called packages.
0:47 So we have two views that require html.
0:50 Change it to templates inside the packages views.
0:53 One's called details and one's called popular.
0:55 Those are the names of the methods.
0:57 So it really helps us understand where those go.
1:00 And most of them are going to use this shared layout.
1:03 So we also created a shared folder
1:04 and we gave the file name a underscore at the beginning
1:07 to say, "This is not meant to be used directly."
1:09 Now it's supposed to be consumed by all the other ones.
1:13 So again, our site's really simple.
1:15 You might not need this yet
1:17 but when you have fifty or a hundred templates
1:19 and many many view files and what-not
1:22 it's really confusing to know
1:23 "I want to change this page real quick, how do I get to it?"
1:26 This will make it so much easier.
1:28 So I definitely encourage you to
1:29 organize your stuff this way.
1:30 But you know, not required by Flask
1:33 more suggested by Michael.