Before test our project, let’s doing some fix in our project. 2
Here we have a navbar, but the link is still not work. Let’s make this link work. 3
Open the visual studio code. 4
First, we need to edit urls.py file. We need to put a name for each url. 5
Let’s set the name of devices url to devices, configure url to configure, verify_config url to verify_config, 6
and log url to log. 7
Next, let’s edit the template where we put navbar script. Which is base.html. 8
Here we can see some link, We have home link here, if we see in the browser, we have home. 9
Let’s edit the url for home. 10
But before that, if we see here, we don’t have a name for the home url yet. 11
Let’s set the name first. 12
Okay. Let’s back to base.hmtl, here let’s define the url. 13
Here we put the name of the url that we have set in the urls.py file. 14
Next, let’s edit the url for Device List. 15
Let’s copy this script for other url 16
Let’s change this to Configure. 17
We don’t need disable class here. 18
Let’s copy the configure link, 19
paste for verify_config, and paste again for log. 20
Let’s change this to verify config, 21
and change this to log. 22
Now let’s back to the browser, refresh. Now let’s try the link. Go to home, 23
go to device list. 24
Go to configure, 25
go to verify config, and finally go to log. 26
Okay now our navbar is working perfectly! 27
Next, if we see in the home page, we have a last event here. But the data in the last 28
event is still dummy data. 29
Let’s edit this to show last 10 event from the database. 30
Open the visual studio code. Edit home function in the views.py. 31
Let’s create a new variable 32
to save the last 10 data from log database. 33
Here we use order_by -id, means we doing a 34
reverse order, so we will get the new data. And here we filter to get only 10 data. 35
Next we need to add this variable to the context. 36
Okay, we have done here. Now let’s edit home.html. 37
Here we can remove this. 38
Then we need to doing a looping to the last_event. 39
Don’t forget to put endfor. 40
We can just remove this 41
Let’s put target in here. 42
This is the action, 43
and this is the status. 44
Finally let’s put the time here. 45
Let’s back to the browser 46
Go to home menu. 47
And here we can see that we don’t have any last event. 48
This is because we don’t have any action yet. 49
Okay, this is the end of this video. Now our project is done! 50
In the next video, we are going to test our application!