1
00:00:05,320 --> 00:00:09,850
Welcome back, everyone, to this lecture, we're going to be creating our first Django project.

2
00:00:11,080 --> 00:00:16,810
Well, we're going to do is explore how to launch the most basic project possible with Django and project

3
00:00:16,810 --> 00:00:21,550
you can think of in Django terms as just your overall web application or website.

4
00:00:22,150 --> 00:00:24,740
Luckily for us, this is done easily at the command prompt.

5
00:00:24,760 --> 00:00:31,060
With the Django Dash admin tool, this Django Dash admin command line tool was automatically installed

6
00:00:31,210 --> 00:00:34,480
when you pip installed Django or installed that Django.

7
00:00:34,870 --> 00:00:39,040
Something to keep in mind, though, is that we're going to be running these commands at the command

8
00:00:39,040 --> 00:00:39,400
line.

9
00:00:39,700 --> 00:00:44,500
So if you installed Django in a virtual environment, you're going to want to remember to activate that

10
00:00:44,500 --> 00:00:45,970
virtual environment first.

11
00:00:46,540 --> 00:00:46,870
OK.

12
00:00:47,320 --> 00:00:54,160
So what do Django Armenta allows us to do is create a set of subdirectories and files for us with a

13
00:00:54,160 --> 00:00:55,030
special command.

14
00:00:56,080 --> 00:01:00,280
So what we're going to end up doing is at the command prompt, we're going to navigate to our desired

15
00:01:00,280 --> 00:01:06,580
location of where we want to work on this project and then type Jango Dash Admin Start Project and then

16
00:01:06,580 --> 00:01:07,720
the name of your website.

17
00:01:08,260 --> 00:01:13,330
So Django admin, that's that special command line capability installed by Django.

18
00:01:13,630 --> 00:01:17,590
And then there's many sub commands that can be called off of Django Dash admin.

19
00:01:17,980 --> 00:01:21,940
And typically, the first sub command that you're gonna end up calling throughout the lifecycle of a

20
00:01:21,940 --> 00:01:24,220
project is the Start Project Command.

21
00:01:24,610 --> 00:01:29,620
So this is the sub command to create a new project directory, and it also automatically creates a set

22
00:01:29,620 --> 00:01:33,040
of directories and files used in most Django projects.

23
00:01:33,220 --> 00:01:35,850
And then this third term is what is up to you.

24
00:01:35,860 --> 00:01:40,300
What do you actually want to choose for the name of your website so you can just call it something like

25
00:01:40,540 --> 00:01:42,400
my underscore site, et cetera?

26
00:01:42,910 --> 00:01:47,110
Something to keep in mind, though, try to use common sense as far as choosing a good name for your

27
00:01:47,110 --> 00:01:48,760
website or Django project.

28
00:01:49,030 --> 00:01:53,050
You probably don't want to call this project something like Django underscore admin.

29
00:01:53,230 --> 00:01:58,150
Otherwise, I would get extremely confusing as far as what Django Admin is actually referring to here.

30
00:01:58,210 --> 00:02:03,790
So just use common sense and try to avoid the actual term Django inside this website name.

31
00:02:04,630 --> 00:02:10,539
So we go to the command prompt and then we run this particular line of code, and that ends up creating

32
00:02:10,539 --> 00:02:14,080
the following set of directories or files and folders for us.

33
00:02:14,470 --> 00:02:16,440
So you'll get something that looks like this.

34
00:02:16,450 --> 00:02:22,420
It's going to see my site as a top level directory and then my site again and then manage that pie.

35
00:02:22,570 --> 00:02:26,000
And keep in mind my site here, that's again, something you can change.

36
00:02:26,020 --> 00:02:27,640
That's the custom name you choose.

37
00:02:28,090 --> 00:02:32,680
So you have this outer my site and this is the root directory.

38
00:02:32,950 --> 00:02:34,600
It's just a container for your project.

39
00:02:34,990 --> 00:02:40,720
Keep in mind, this name doesn't technically matter to Django, so you can rename this top level project

40
00:02:40,720 --> 00:02:41,880
folder or anything you want.

41
00:02:41,890 --> 00:02:48,550
So you could rename this very top level directory like homework or practice, etc. Django won't complain

42
00:02:49,000 --> 00:02:51,730
because it doesn't really care that that matches the project name.

43
00:02:52,420 --> 00:02:58,890
Then what it also creates is directly underneath this top level root directory container is managed.

44
00:02:58,890 --> 00:03:04,810
Stop Pi manage that PI is actually this python file for a bunch of command line utilities that lets

45
00:03:04,810 --> 00:03:07,660
you interact with the Django project in various ways.

46
00:03:07,990 --> 00:03:11,860
And we're gonna be talking a lot more about Django Admin and manage that pie.

47
00:03:12,130 --> 00:03:14,500
They actually have some overlap and capabilities.

48
00:03:14,830 --> 00:03:16,480
They're going to see us throughout the course.

49
00:03:16,720 --> 00:03:18,340
Run different commands off.

50
00:03:18,340 --> 00:03:19,300
Manage that pie.

51
00:03:19,420 --> 00:03:24,160
You can think of it as its namesake as just the way to overall manage your project.

52
00:03:24,550 --> 00:03:28,360
And then let's move on to this sub directory that is also created called my site.

53
00:03:28,660 --> 00:03:29,530
So that's a folder.

54
00:03:29,830 --> 00:03:34,120
And when you open this folder, what you're going to end up getting is a bunch of that py files within

55
00:03:34,120 --> 00:03:34,240
it.

56
00:03:35,050 --> 00:03:40,340
So the first one is the in it that py file, as we already know from modules and then Python.

57
00:03:40,630 --> 00:03:45,190
This is just an empty file that tells Python that, hey, this directory should be considered a Python

58
00:03:45,190 --> 00:03:45,760
package.

59
00:03:46,600 --> 00:03:48,250
Next, we have settings that pie.

60
00:03:48,580 --> 00:03:54,520
This is a settings and configuration file that we can edit for the settings that are going to be across

61
00:03:54,520 --> 00:03:55,930
the entire Django project.

62
00:03:56,290 --> 00:04:00,640
Later on, we'll talk about editing settings for specific tasks in our projects.

63
00:04:01,620 --> 00:04:03,330
Then we have the URLs that pie.

64
00:04:03,720 --> 00:04:09,120
What's nice about this is this is essentially acting as we're we're going to point the views through

65
00:04:09,140 --> 00:04:14,010
our website so you can think of this almost like a table of contents for the Django powered site.

66
00:04:14,250 --> 00:04:17,790
You just say, Hey, this this view to this URL.

67
00:04:17,820 --> 00:04:21,060
Again, we're going to talk a lot more about views and URLs later on.

68
00:04:21,690 --> 00:04:24,480
And then you have an SGI that PI file.

69
00:04:24,720 --> 00:04:28,800
That's an entry point for a SGI compatible web servers to serve your project.

70
00:04:29,040 --> 00:04:31,860
We'll talk about that and what that actually means in more detail later on.

71
00:04:32,220 --> 00:04:39,210
And then similarly, there is a SGI, which is an entry point for WSI compatible web servers to serve

72
00:04:39,210 --> 00:04:39,780
your project.

73
00:04:40,170 --> 00:04:42,690
We'll talk about those two and a lot more detail later on.

74
00:04:42,720 --> 00:04:48,150
But just think about this as being automatically created for you, and you'll typically have all these

75
00:04:48,150 --> 00:04:50,760
files in a project when you're just starting off.

76
00:04:50,880 --> 00:04:54,870
And then later on, we're going to edit these work with them and see how to actually use them.

77
00:04:55,260 --> 00:04:59,100
For right now, though, let's go ahead and practice creating this, and then we're actually going to

78
00:04:59,100 --> 00:05:04,230
be able to run the server through the manage that file and see our Django project live.

79
00:05:04,560 --> 00:05:07,320
So we're going to create a very first Django project.

80
00:05:07,590 --> 00:05:09,150
Let's head over to Visual Studio code.

81
00:05:09,300 --> 00:05:14,700
All right, here I have a Visual Studio code recall that I have this top level folder called Django

82
00:05:14,700 --> 00:05:15,870
Lectures, et cetera.

83
00:05:16,230 --> 00:05:21,570
Go ahead and navigate using your command, prompt or terminal here to wherever you actually want to

84
00:05:21,570 --> 00:05:23,710
work with this particular project.

85
00:05:23,730 --> 00:05:29,520
So if you want to, you could use code to change directory and then start to go back up a directory.

86
00:05:29,580 --> 00:05:35,130
If you want it to just work with all these files on your desktop, or you could say CD and then start

87
00:05:35,130 --> 00:05:40,800
typing in the name of wherever you want it to work, such as Django lectures on my desktop and then

88
00:05:40,800 --> 00:05:44,370
change directories back down into wherever you happen to be working.

89
00:05:44,610 --> 00:05:45,810
So it's really up to you.

90
00:05:46,050 --> 00:05:50,580
Sometimes it's easier to change where you are here in the Explorer or say file.

91
00:05:50,610 --> 00:05:56,250
And then if you go file open folder, you could open a folder somewhere else completely different on

92
00:05:56,250 --> 00:05:59,850
your computer and then relaunch the terminal there in order to get the terminal to connect.

93
00:06:00,030 --> 00:06:00,900
So keep that in mind.

94
00:06:01,050 --> 00:06:02,220
Lots of different ways you can do this.

95
00:06:02,580 --> 00:06:05,940
I'll go ahead and launch my project inside Django lectures.

96
00:06:06,480 --> 00:06:11,500
The next thing you want to be aware of is if you're happening to be using a virtual environment, are

97
00:06:11,520 --> 00:06:15,300
going to want to activate the virtual environment right now before you start calling these commands,

98
00:06:15,510 --> 00:06:18,540
especially if Django's only installed in your virtual environment.

99
00:06:18,870 --> 00:06:23,910
I was going to do this on my top level installation of Python, and then we're going to do here is actually

100
00:06:23,910 --> 00:06:24,720
start the project.

101
00:06:25,320 --> 00:06:31,380
So I say Django, that admin space and then we say Start Project.

102
00:06:32,780 --> 00:06:35,750
Space and then whatever you want to actually call that project.

103
00:06:36,140 --> 00:06:42,530
So let's call this project my site or my website, whatever you want to actually call it, enter and

104
00:06:42,530 --> 00:06:46,010
then nothing was actually going to be reported for you at the terminal.

105
00:06:46,370 --> 00:06:49,450
But if you come back up here, you'll notice we have those directories I mentioned.

106
00:06:49,460 --> 00:06:54,880
We have my site, my site, we have the files already talked about settings, up pi, et cetera.

107
00:06:54,890 --> 00:06:58,810
You can see the URLs that PI, this is going to connect things, et cetera.

108
00:06:58,820 --> 00:07:01,880
And then you have managed that pi and all that jazz.

109
00:07:02,000 --> 00:07:06,170
And we're going to talk about the details of these files later on in the course.

110
00:07:06,530 --> 00:07:11,750
But you'll notice URLs actually already has things set up, such as the admin site, which is kind of

111
00:07:11,750 --> 00:07:12,140
interesting.

112
00:07:12,140 --> 00:07:15,110
The path is admin, so we'll talk about that later on.

113
00:07:15,180 --> 00:07:21,770
You can see there is a ton of functionality already included inside of Django, so this helps really

114
00:07:21,770 --> 00:07:26,630
speed up your development when you can launch something like this with just a single line of code.

115
00:07:26,930 --> 00:07:32,110
Now again, we don't understand every single file does yet, but as you go and progress throughout this

116
00:07:32,120 --> 00:07:36,950
course, you're going to see the power of Django and its ability to quickly spin up a project like this.

117
00:07:37,400 --> 00:07:41,030
For now, we're going to use manage that PI and manage that.

118
00:07:41,030 --> 00:07:47,990
PI has a bunch of different command line arguments that we can actually use that are called from Django,

119
00:07:48,350 --> 00:07:51,140
and the first we're going to be doing is the run server command.

120
00:07:51,590 --> 00:07:54,860
So we'll come back down here to our terminal and I'm going to say Python.

121
00:07:56,200 --> 00:07:57,440
I'm going to call.

122
00:07:57,460 --> 00:07:59,890
Actually, we have to make sure we're in the same directory.

123
00:08:00,490 --> 00:08:04,930
So keep in mind right now I'm enjoying your lectures, but I actually want to be in the same directory

124
00:08:04,930 --> 00:08:06,280
as managed up pie.

125
00:08:06,760 --> 00:08:07,840
So I want to see the.

126
00:08:09,040 --> 00:08:15,970
And then go to my site, and if you want to confirm whether or not the managed file is there, you can

127
00:08:15,970 --> 00:08:21,790
say else if you are on Mac OS or Linux or if you're on Windows, you say the air to show the directory

128
00:08:22,090 --> 00:08:25,600
and essentially we want to do is confirm that managed up high is there.

129
00:08:26,110 --> 00:08:27,520
So you can see it's a little confusing.

130
00:08:27,520 --> 00:08:32,260
They you have to my site folders here or my site directories, so keep that in mind.

131
00:08:32,320 --> 00:08:37,120
It can be kind of confusing and sometimes you think you're at the top level directory or the root directory

132
00:08:37,330 --> 00:08:40,120
when you're actually inside here and you start calling managed up high.

133
00:08:40,120 --> 00:08:42,690
But it says, sorry, manage that pie doesn't exist.

134
00:08:42,700 --> 00:08:43,630
Just keep that in mind.

135
00:08:43,630 --> 00:08:45,880
You have these two directories that have the same name.

136
00:08:46,240 --> 00:08:46,570
OK.

137
00:08:46,990 --> 00:08:50,200
So let me clear that I'll skip seals since I'm on windows.

138
00:08:50,230 --> 00:08:55,010
It's just the word clear if you are on Mac OS or Linux, so type class.

139
00:08:55,030 --> 00:08:55,780
OK, now I know.

140
00:08:55,780 --> 00:08:56,800
Manage that pies there.

141
00:08:57,070 --> 00:08:58,270
I'm going to say Python.

142
00:08:59,590 --> 00:09:04,960
Managed up high note that I'm not just calling Python and then hitting enter, otherwise that just starts

143
00:09:04,960 --> 00:09:05,440
Python.

144
00:09:05,920 --> 00:09:07,060
So I'm going to quit that again.

145
00:09:07,060 --> 00:09:08,740
That's another really common beginner mistake.

146
00:09:09,190 --> 00:09:09,970
So I'm gonna quit that.

147
00:09:10,060 --> 00:09:13,830
Let's go ahead and clear that again, I'm going to say Python, and I'm actually going to run managed

148
00:09:13,840 --> 00:09:14,260
up by it.

149
00:09:15,200 --> 00:09:19,610
So, say managed that pie, and then there's a command line argument they can pass in to manage that

150
00:09:19,610 --> 00:09:19,940
pie.

151
00:09:20,330 --> 00:09:24,170
And that is run server all one word.

152
00:09:25,190 --> 00:09:28,190
And this is actually going to essentially launch the website.

153
00:09:28,490 --> 00:09:31,320
It's going to complain that you have some unemployed migrations.

154
00:09:31,340 --> 00:09:32,690
Don't worry about that right now.

155
00:09:32,970 --> 00:09:37,670
Let's do more with things like authorization, administration sessions, cetera.

156
00:09:38,120 --> 00:09:42,740
Well, you should notice is it said, Hey, I'm starting the development server right here.

157
00:09:43,550 --> 00:09:47,600
And notice it has an actual what looks like a website address.

158
00:09:47,660 --> 00:09:48,890
So we're going to control.

159
00:09:48,890 --> 00:09:50,930
Click this in order to follow the link.

160
00:09:51,260 --> 00:09:55,100
Well, you should be careful of is do not use control C. I'll show you what happens if you lose control.

161
00:09:55,100 --> 00:09:59,570
C. So being a mistake, I see all the time student highlights this.

162
00:09:59,570 --> 00:10:04,400
They say control c and either they get something here or hey, some key bindings, don't go to the terminal

163
00:10:04,400 --> 00:10:05,000
by default.

164
00:10:05,030 --> 00:10:12,770
It's actually kind of a nice feature, but in other like a Mac OS terminals or different IDs that actually

165
00:10:12,770 --> 00:10:13,490
kills the server.

166
00:10:13,490 --> 00:10:15,620
So Control C is super common for killing the server.

167
00:10:15,890 --> 00:10:19,100
So just keep that in mind, you want to make sure that you come back to this command line.

168
00:10:19,310 --> 00:10:21,620
And he didn't actually say Control C to copy this away.

169
00:10:21,890 --> 00:10:23,050
But let's go to this.

170
00:10:23,060 --> 00:10:23,630
I'm going to control.

171
00:10:23,630 --> 00:10:29,030
Click the follow this link, and when you follow this link, you should get some sort of application

172
00:10:29,030 --> 00:10:31,580
or page that says, Hey, the install works successfully.

173
00:10:31,940 --> 00:10:36,560
Keep in mind, each version of Django usually has a different picture and a different look.

174
00:10:36,590 --> 00:10:42,020
So by the time you're running this in Django, for which I'm right now showing you for three point two

175
00:10:42,020 --> 00:10:44,780
sons, four isn't out at the time of me filming this.

176
00:10:45,260 --> 00:10:47,900
Keep in mind, it's maybe a slightly different picture.

177
00:10:48,050 --> 00:10:52,550
So other than that, you should see some sort of OK, everything's working page.

178
00:10:52,970 --> 00:10:57,830
The last thing I want to mention is we are right now running this at the default port, which is 8000.

179
00:10:58,130 --> 00:11:01,640
But as a second argument, you can actually tell it to run at a different port.

180
00:11:02,090 --> 00:11:04,790
So going to come back to jingle lectures.

181
00:11:04,820 --> 00:11:08,150
Notice that you start getting all these get requests information.

182
00:11:08,180 --> 00:11:09,860
We'll talk a lot more about that later on.

183
00:11:10,220 --> 00:11:16,160
But what I'm going to do here is do control C to actually kill this say class here, and I'm going to

184
00:11:16,160 --> 00:11:18,470
say python managed pie.

185
00:11:19,740 --> 00:11:26,160
Run server, and then let's say, instead of the 8000 port, I wanted to run it at 88 port because maybe

186
00:11:26,160 --> 00:11:28,950
something else on my computer is running 8000 port.

187
00:11:28,980 --> 00:11:32,510
You just type that in as a secondary command, 80 80.

188
00:11:33,030 --> 00:11:35,100
Then you go ahead and hit.

189
00:11:35,190 --> 00:11:41,070
Enter here and you'll notice it says now it's running at one two seven zero zero one 80 80 and you can

190
00:11:41,070 --> 00:11:41,400
control.

191
00:11:41,400 --> 00:11:42,660
Click to follow that link.

192
00:11:43,290 --> 00:11:43,680
OK.

193
00:11:44,160 --> 00:11:49,800
Again, we'll talk about all these kind of warnings etc migrations, but for right now, you have successfully

194
00:11:49,800 --> 00:11:51,990
run your first Durango project.

195
00:11:52,460 --> 00:11:53,460
We're going to do next.

196
00:11:53,550 --> 00:11:57,090
Let's talk about the difference between projects and Django apps.

197
00:11:57,360 --> 00:11:59,700
And there's a little bit of confusing terminology there.

198
00:11:59,970 --> 00:12:02,700
So let's take a lecture to address that coming up next.

199
00:12:03,240 --> 00:12:03,660
Thanks.

200
00:12:03,690 --> 00:12:04,230
I'll see you there.

