1
00:00:05,160 --> 00:00:10,500
Welcome back, everyone, to this lecture covering Django Admin, just the very basics, what we're

2
00:00:10,500 --> 00:00:15,450
going to do is explore Django administration, and there's typically two things that we want to check

3
00:00:15,450 --> 00:00:16,079
out first.

4
00:00:16,410 --> 00:00:21,750
One is the fact that if you were to go to your domain dot com, in our case, there's just one two seven

5
00:00:21,750 --> 00:00:24,870
zero zero one port, eight thousand four slash admin.

6
00:00:25,170 --> 00:00:29,790
You're going to realize that there's actually an extension already automatically created for you by

7
00:00:29,790 --> 00:00:30,240
Django.

8
00:00:30,480 --> 00:00:36,810
In fact, the whole Django admin system just comes and automatically built itself based off the models

9
00:00:36,810 --> 00:00:38,070
and views you create.

10
00:00:38,310 --> 00:00:43,140
It's an amazing feature that I really think is going to impress you when you realize you didn't have

11
00:00:43,140 --> 00:00:45,930
to do any extra code in order to have this happen.

12
00:00:46,380 --> 00:00:52,020
Then once we actually see that admin extension working, we're going to create a super user at the command

13
00:00:52,020 --> 00:00:58,170
line using the managed PY file that can allow us to have a username and password to actually log in

14
00:00:58,170 --> 00:01:00,460
to the admin view to get started.

15
00:01:00,510 --> 00:01:05,400
I'm actually going to go to Django Project RT.com to show you what this admin looks like.

16
00:01:05,550 --> 00:01:10,230
OK, here I am at Django Project comes the official page for the documentation.

17
00:01:10,650 --> 00:01:19,590
What I want you to do is go to Django Project e-Comm and then say Forward Slash Admin, 80 m i n and

18
00:01:19,590 --> 00:01:20,550
then hit enter.

19
00:01:20,970 --> 00:01:28,140
And what you notice is it's actually going to reroute you to admin forward slash login because this

20
00:01:28,140 --> 00:01:32,510
is the administration view for Django and you're technically not logged in yet.

21
00:01:32,670 --> 00:01:38,820
In order to be authorized to actually see the administration of this Django site now, clearly we don't

22
00:01:38,820 --> 00:01:44,430
have a username or password for this Django administration, but this is what the default Django administration

23
00:01:44,430 --> 00:01:44,910
looks like.

24
00:01:45,270 --> 00:01:51,030
Obviously, Django Project is running off of Django itself, and by default, Django actually creates

25
00:01:51,030 --> 00:01:52,590
a Django administration page.

26
00:01:53,010 --> 00:01:58,590
Let's see this on our site that we just created in the previous two lectures here at our site.

27
00:01:58,770 --> 00:02:02,670
Remember, we have list, add and delete, and I can just add a new car.

28
00:02:03,090 --> 00:02:07,140
For example, I can add a Ford from the year 2023.

29
00:02:07,230 --> 00:02:08,009
Go ahead, submit.

30
00:02:08,250 --> 00:02:09,509
And now that's added in.

31
00:02:09,960 --> 00:02:13,590
What I'm going to do is instead of checking out the cars and list app.

32
00:02:14,670 --> 00:02:20,940
I'm going to say our domain name, which is one two seven zero zero one 8000 and then go to forward

33
00:02:20,940 --> 00:02:24,060
slash admin, I hit Enter.

34
00:02:24,210 --> 00:02:27,330
And notice that we also have this Django administration page.

35
00:02:27,540 --> 00:02:31,950
We didn't have to do any coding in order for this to just work right off the bat.

36
00:02:32,430 --> 00:02:36,300
What we do need to do, though, is create up a username and password.

37
00:02:36,660 --> 00:02:41,760
That combination of a username and password is known as a super user within Django.

38
00:02:42,120 --> 00:02:45,540
This is to clarify the difference between a typical user of your website.

39
00:02:45,810 --> 00:02:51,690
Maybe if you're running something like Facebook or Instagram, where a typical user is just someone

40
00:02:51,690 --> 00:02:57,270
on their actual social network, a super user would be someone that actually has admin capabilities

41
00:02:57,510 --> 00:03:00,840
and could possibly actually edit points in your models.

42
00:03:01,110 --> 00:03:04,170
So let's see how this works in order to create a super user.

43
00:03:04,200 --> 00:03:07,440
We have to go back to Visual Studio code and do it at the command line.

44
00:03:07,470 --> 00:03:09,960
OK, here I am back at Visual Studio Code.

45
00:03:10,260 --> 00:03:15,300
I have my site running, but in order to create a super user, I need to stop this right now.

46
00:03:15,300 --> 00:03:16,230
So I'm going to say control.

47
00:03:16,230 --> 00:03:16,800
See here.

48
00:03:16,830 --> 00:03:18,410
Make sure the site's no longer running.

49
00:03:18,840 --> 00:03:23,550
And then what I can do is, say, python managed dot pie.

50
00:03:24,060 --> 00:03:28,200
And then the command is create super user all one word.

51
00:03:28,650 --> 00:03:34,470
And obviously, this is a functionality command built into manage the pie that allows us to easily create

52
00:03:34,470 --> 00:03:36,450
a super user, something to keep in mind.

53
00:03:36,450 --> 00:03:41,670
Those after you run this, it's going to ask you for your inputs like a username, email address and

54
00:03:41,670 --> 00:03:43,650
password and then confirmed that password.

55
00:03:43,830 --> 00:03:48,840
I should also note the password is going to be invisible as you type it for security purposes.

56
00:03:49,110 --> 00:03:52,920
That way, someone looking over your shoulder can actually know your password by just looking at the

57
00:03:52,920 --> 00:03:53,310
screen.

58
00:03:54,380 --> 00:04:00,410
So I hit Python, managed up high create super user, and what you can do is have it use your default

59
00:04:00,410 --> 00:04:02,270
username from your actual computer.

60
00:04:02,300 --> 00:04:03,800
You can see mine right there, Marcial.

61
00:04:04,160 --> 00:04:09,710
But what I'm going to do is just create another username so we can understand that we were actually

62
00:04:09,710 --> 00:04:10,400
the ones created.

63
00:04:10,970 --> 00:04:17,450
So let's imagine I have a person on my team named Jan, and I want her to have an admin.

64
00:04:18,140 --> 00:04:27,380
So I'm going to say Jan or Jane underscore admin is the username I enter, then her email address right

65
00:04:27,380 --> 00:04:28,580
now, I'm just going to make this up.

66
00:04:28,910 --> 00:04:33,680
Obviously, the point of this email address would be if this administrator ever needed to reset their

67
00:04:33,680 --> 00:04:35,390
password, we could send them an email here.

68
00:04:35,930 --> 00:04:38,210
So we'll just say Jan or Jane at.

69
00:04:39,530 --> 00:04:41,120
Or, yeah, Tuscon, that's fine.

70
00:04:42,290 --> 00:04:42,710
Enter.

71
00:04:43,010 --> 00:04:44,630
And now it's time for the password.

72
00:04:45,020 --> 00:04:47,690
There are going to be some limitations to this password.

73
00:04:47,690 --> 00:04:50,930
It does have to meet a certain number of characters and can't be too simple.

74
00:04:51,230 --> 00:04:52,970
So you can't really just type in password.

75
00:04:53,270 --> 00:04:55,290
So we will just use a bad password.

76
00:04:55,310 --> 00:05:02,510
I'm going to type in Jane Password J A and e p a se w o r d.

77
00:05:02,750 --> 00:05:07,030
Again, keep in mind, it is invisible, and it's not apparent that I actually typed something there,

78
00:05:07,370 --> 00:05:10,190
but I'm going to hit enter and now it's time for the password again.

79
00:05:10,610 --> 00:05:18,080
So I'm just typing a and e p a S.W.O.R.D. Jane password, OK?

80
00:05:18,200 --> 00:05:22,790
And if those didn't match, you would ask us to redo those passwords, but the super user has been created

81
00:05:22,790 --> 00:05:23,420
successfully.

82
00:05:23,900 --> 00:05:27,380
Again, one of the most common questions I get is why is my password not typing anything?

83
00:05:27,380 --> 00:05:29,270
It's invisible for security purposes.

84
00:05:29,630 --> 00:05:35,060
So we just created this super user Jane Admin with Jane Password as the password.

85
00:05:35,420 --> 00:05:38,000
And what I'm going to do is run our server again.

86
00:05:38,000 --> 00:05:44,810
We're gonna say Python managed a pie run server, and let's actually explore what is on the admin side

87
00:05:44,810 --> 00:05:45,200
of things.

88
00:05:46,000 --> 00:05:48,980
So enter there and it looks like we are running.

89
00:05:48,980 --> 00:05:50,300
So let's head back to the browser.

90
00:05:50,750 --> 00:05:51,440
OK, here I am.

91
00:05:51,440 --> 00:05:56,190
Back at the browser I went to forward slash admin got rerouted to login.

92
00:05:56,240 --> 00:05:58,790
Now I'm going to type in the username we created.

93
00:05:58,790 --> 00:05:59,930
Jane underscore admin.

94
00:06:00,380 --> 00:06:02,560
And now let's create the actual password.

95
00:06:02,570 --> 00:06:05,750
In this case, I typed out Jane password.

96
00:06:06,770 --> 00:06:07,790
Can I hit log in?

97
00:06:08,750 --> 00:06:13,790
And if you successfully pass, then the correct username and password combo, then you should have created

98
00:06:13,790 --> 00:06:16,550
the super user and you should see something like this.

99
00:06:17,120 --> 00:06:23,330
You'll notice by default, there's only essentially authentication authorization under site administration.

100
00:06:23,870 --> 00:06:27,920
So what you can do is you can view the site, you can actually change your password here, or you can

101
00:06:27,920 --> 00:06:28,880
just log out.

102
00:06:29,270 --> 00:06:32,090
We will talk about authentication authorization later on.

103
00:06:32,450 --> 00:06:36,950
So there's actually a built in series of authentication authorization capabilities when jingo.

104
00:06:37,190 --> 00:06:40,790
We can actually create groups which are made up of users.

105
00:06:41,090 --> 00:06:47,390
And right now, we only have one user, which is kind of a super user and that user is me, Jane Admin

106
00:06:47,630 --> 00:06:48,260
Jane Test.

107
00:06:48,530 --> 00:06:50,120
There's no first name or last name right now.

108
00:06:50,420 --> 00:06:51,620
Staff status.

109
00:06:51,620 --> 00:06:55,250
That little checkmark essentially says, Hey, by the way, I'm staff here.

110
00:06:55,580 --> 00:06:57,230
I can filter this automatically.

111
00:06:57,230 --> 00:07:03,270
So notice just how amazing this is the fact that all this material was created for us by default.

112
00:07:03,740 --> 00:07:09,200
Now, typically, what you also want to have here, depending on your website, are the models themselves.

113
00:07:09,740 --> 00:07:16,070
So what I want to do is add in our car model and connect it to Django administration.

114
00:07:16,550 --> 00:07:18,590
I'm going to do that in the very next lecture.

