1
00:00:00,710 --> 00:00:01,700
Hey, welcome back.

2
00:00:01,700 --> 00:00:08,870
In this video, we will set up our Django project, but before that, you need to create a new PyCharm

3
00:00:08,870 --> 00:00:09,740
project.

4
00:00:09,770 --> 00:00:10,940
I've done that already.

5
00:00:10,940 --> 00:00:13,460
So that's my pie chart project.

6
00:00:13,640 --> 00:00:20,120
I don't have any files for now except of the Venv directory which was created by PyCharm.

7
00:00:20,120 --> 00:00:29,120
So let's set up a Django project now with Flask, you don't really need to set up a flask project,

8
00:00:29,120 --> 00:00:32,570
but with Django, things work a bit differently.

9
00:00:32,570 --> 00:00:41,120
So with Flask, what we do is we create a new python file and start coding in that file.

10
00:00:41,900 --> 00:00:43,130
With Django.

11
00:00:43,160 --> 00:00:45,840
You don't create those files yourself.

12
00:00:45,860 --> 00:00:47,570
Django will create it for you.

13
00:00:47,570 --> 00:00:49,730
But first of all, we need to install Django.

14
00:00:49,730 --> 00:00:51,230
So that's the very first step.

15
00:00:51,230 --> 00:00:53,000
So please go to the terminal.

16
00:00:53,840 --> 00:01:00,500
So my venv is activated so I can just run PIP, install django and press enter.

17
00:01:03,360 --> 00:01:11,250
Writes, My Django was installed successfully so I can close the terminal and now we want to set up

18
00:01:11,250 --> 00:01:12,570
the Django project.

19
00:01:12,570 --> 00:01:17,100
So we have the PyCharm directory here, we have Django installed.

20
00:01:17,130 --> 00:01:20,970
Let's set up the project to set up the project again.

21
00:01:20,970 --> 00:01:34,440
You want to go to the terminal and type in Django minus admin start project my site dot.

22
00:01:34,650 --> 00:01:37,310
And what is this command?

23
00:01:37,320 --> 00:01:39,270
Well, Django admin.

24
00:01:39,270 --> 00:01:43,260
Django minus admin is one of the Django commands.

25
00:01:43,260 --> 00:01:51,000
So your operating system should recognize this now because when we install Django, this was added to

26
00:01:51,000 --> 00:01:53,700
the path of our operating system.

27
00:01:53,700 --> 00:01:57,840
So you can access this command from your operating system terminal.

28
00:01:57,840 --> 00:02:00,750
And then this is part of this command.

29
00:02:00,750 --> 00:02:03,870
So we want to set up a project, right?

30
00:02:03,870 --> 00:02:08,639
So these are the commands and this is a name you want to give to your project.

31
00:02:08,639 --> 00:02:11,400
So I do recommend to just write my site.

32
00:02:11,400 --> 00:02:18,660
And then the dot means that my site, this directory will be created in the current directory, which

33
00:02:18,660 --> 00:02:22,080
is app 17 Django form in my case.

34
00:02:22,080 --> 00:02:24,840
So the root directory of our project.

35
00:02:24,840 --> 00:02:30,000
So my site will be created when I run this command.

36
00:02:30,150 --> 00:02:31,080
Let's see.

37
00:02:31,080 --> 00:02:36,720
So I just ran it and perhaps you need some seconds for this to refresh the directory.

38
00:02:36,720 --> 00:02:41,280
Or you can go and reload from disk to refresh it.

39
00:02:41,280 --> 00:02:42,360
So there we go.

40
00:02:42,360 --> 00:02:49,800
That's my site directory and this directory has a few.py files inside.

41
00:02:50,130 --> 00:02:53,070
Also outside my site.

42
00:02:53,070 --> 00:02:56,130
So still in app 17 django form.

43
00:02:56,130 --> 00:02:58,350
We also have manage.py.

44
00:02:58,980 --> 00:03:00,990
So what are these files.

45
00:03:00,990 --> 00:03:02,970
Well these.

46
00:03:02,970 --> 00:03:07,150
Some of these are configuration files and you shouldn't change them.

47
00:03:07,150 --> 00:03:09,190
So please just view them.

48
00:03:09,190 --> 00:03:15,070
You can double click and and look at what they are, but don't change anything.

49
00:03:15,070 --> 00:03:17,860
We will need to change some of the configurations.

50
00:03:17,860 --> 00:03:23,230
But I'll tell you what exactly and I'll explain why we change that so that you know what you're doing.

51
00:03:23,230 --> 00:03:25,030
So for now, please don't change them.

52
00:03:25,390 --> 00:03:33,640
So this here and also manage.py right now, what we did so far is we created a project.

53
00:03:33,640 --> 00:03:37,990
So this is known as Django Project in the Django vocabulary.

54
00:03:38,020 --> 00:03:40,720
Now we want to create a Django app.

55
00:03:40,720 --> 00:03:42,220
So we have a project.

56
00:03:42,220 --> 00:03:44,980
We want to create an app to create an app.

57
00:03:45,010 --> 00:03:47,170
You run the command Python.

58
00:03:48,020 --> 00:03:49,970
Manage.py.

59
00:03:50,000 --> 00:03:57,800
You see now so python is just the python commands and manage.py is the file we have in the current directory.

60
00:03:57,800 --> 00:04:06,290
So you see I am in app 17 django form and in this directory I have this manage.py file.

61
00:04:06,290 --> 00:04:09,620
So that means python will execute this file.

62
00:04:09,650 --> 00:04:11,000
Manage.py.

63
00:04:11,360 --> 00:04:21,649
Now this file is set up in a way that it expects commands and one of the commands is start app.

64
00:04:21,649 --> 00:04:24,560
Start app will create an app.

65
00:04:24,560 --> 00:04:30,440
So a Django app, the web app we want to create, which in our case is the application, the job application

66
00:04:30,440 --> 00:04:31,130
form.

67
00:04:31,130 --> 00:04:33,770
And then you want to give a name to that app.

68
00:04:35,570 --> 00:04:39,590
I do recommend to use an underscore if you have multiple words.

69
00:04:39,590 --> 00:04:45,950
So in my case this would be job underscore application and execute with enter.

70
00:04:46,310 --> 00:04:50,430
Once you execute it, a new directory should be displayed here.

71
00:04:50,430 --> 00:04:51,990
So let's refresh.

72
00:04:52,230 --> 00:04:54,420
You can refresh if it doesn't show up.

73
00:04:54,420 --> 00:04:55,770
And yeah, so there we go.

74
00:04:55,800 --> 00:04:58,680
Job application, job underscore application.

75
00:04:58,680 --> 00:05:05,010
So in the project root directory we have job application, my site and manage.py.

76
00:05:06,350 --> 00:05:15,410
Job application also has some configuration files, which are the configuration files of the app, not

77
00:05:15,410 --> 00:05:17,810
the configuration files of the project.

78
00:05:17,840 --> 00:05:25,880
So under my side, we have the configuration files of the project and also manage.py is a configuration

79
00:05:25,880 --> 00:05:32,570
file of the project, but a project can have multiple apps and each app will have its own directory.

80
00:05:32,570 --> 00:05:41,480
So now we have one app job application, but perhaps you want to expand your site, your website, perhaps

81
00:05:41,480 --> 00:05:44,840
you want to also add a blog section on your website.

82
00:05:44,840 --> 00:05:45,410
Right?

83
00:05:45,440 --> 00:05:50,360
For that you would create a new app using this command again.

84
00:05:50,360 --> 00:05:57,320
So Python manage Start app and you would say something like blog for the name and then a new directory

85
00:05:57,320 --> 00:06:00,380
would be created here named blog.

86
00:06:00,380 --> 00:06:03,740
We don't want to do that, so please don't execute that.

87
00:06:04,010 --> 00:06:07,270
And so a project may contain multiple apps.

88
00:06:07,290 --> 00:06:14,730
Now we are almost ready to run our Django app so that we can see the results on the web page.

89
00:06:15,270 --> 00:06:24,480
But just before we do that, now, we want to modify one of the configuration files, the settings configuration

90
00:06:24,480 --> 00:06:25,740
file of our project.

91
00:06:25,740 --> 00:06:34,950
So go to my site settings, double click that, and we want to register our app with the project.

92
00:06:34,950 --> 00:06:40,580
So you want to locate the installed app variable, which is equal to a list.

93
00:06:40,590 --> 00:06:43,690
So these are default apps.

94
00:06:43,720 --> 00:06:51,000
All the projects you don't want to change them, but you want to add a new item to this list.

95
00:06:51,000 --> 00:06:55,260
So it's a list spanning across multiple lines.

96
00:06:55,260 --> 00:07:01,800
So in here you want to press enter after the comma and then create a string.

97
00:07:01,950 --> 00:07:06,900
I'll use single quotes to be consistent with these other strings here and here.

98
00:07:06,900 --> 00:07:13,770
You want to type in the correct name of your app job underscore application.

99
00:07:13,950 --> 00:07:18,420
It's also good to have a comma here in case you add more apps in the future.

100
00:07:18,420 --> 00:07:26,850
And once you have made that change, save the file with Ctrl or command s Now close the file so that

101
00:07:26,850 --> 00:07:35,490
you don't do any unwanted changes and then we're ready to run our app and see the output on the browser.

102
00:07:35,760 --> 00:07:44,130
Now when we run a Flask app, what we did is we went to the Main.py file or app dot Pi where our code

103
00:07:44,130 --> 00:07:49,200
was located, and then we run that file as we normally do with Python files.

104
00:07:49,200 --> 00:07:51,450
So just right click and execute that file.

105
00:07:51,450 --> 00:07:54,390
Now running a Django app is a bit different.

106
00:07:54,390 --> 00:07:56,010
The process is a bit different.

107
00:07:56,040 --> 00:08:04,650
You want to use a particular command in your terminal, so please type in Python manage.py followed

108
00:08:04,650 --> 00:08:07,350
by the run server command.

109
00:08:07,350 --> 00:08:16,320
So we are executing the same file which we executed during the creation of our job application app.

110
00:08:16,500 --> 00:08:19,410
But this time we don't use the START app command.

111
00:08:19,410 --> 00:08:21,660
We use the run server command.

112
00:08:21,660 --> 00:08:26,280
So execute that and you should see this output.

113
00:08:26,280 --> 00:08:29,820
So you want to go to that link.

114
00:08:29,820 --> 00:08:36,510
So either click on that link or right click to open it somewhere and you will see something like this.

115
00:08:36,510 --> 00:08:43,650
So that's the front page of your Django web app of your Django website.

116
00:08:43,830 --> 00:08:54,330
So Django, initially it shows some default view here, but later when we add an index.html file for

117
00:08:54,330 --> 00:09:02,160
our app and then we instruct Django that when the home page is visited, that index.html should show

118
00:09:02,160 --> 00:09:02,850
up here.

119
00:09:02,850 --> 00:09:08,070
So then this view will reflect the contents of index.html.

120
00:09:08,070 --> 00:09:10,110
But for now this is what we get.

121
00:09:10,470 --> 00:09:16,830
So with that we have set up a Django project and a Django app successfully.

122
00:09:16,830 --> 00:09:21,330
So next is we need to add content to our app.

123
00:09:21,330 --> 00:09:22,980
So let's do that in the next videos.

124
00:09:23,010 --> 00:09:23,340
See you.

