In the previous video, we create friends models in our Django project. 2
We also add some of our friends to the database. 3
Now let’s display all of our friends to the Django page. 4
To doing that, we need to pass our friends as a context from views.py to template file. 5
Let’s go to visual studio code and open views.py. 6
First, we need to import Friends from models. 7
Now we can get all of our friends from database using script like this. 8
Next, we need to pass all_friends variable as context. 9
Now open the template file. 10
Let’s print the list of our friends here, to print all of friends, 11
we can use looping. To do looping in template file, we need to use curly braces 12
and percents tag like this. The script will be, “for friend in all_friends”, 13
all_friends is a context variable that we have defined in the views.py file. To print the name, we 14
To print the name, we can use friend.name 15
and to print the age, we can use friend.age. 16
Let’s open the browser and look what happened. 17
Cool ! Now we have the list of our friends here. 18
This is the end of this video, also this is the last video that cover about Django fundamentals. 19
If you have any questions about Django fundamentals, Fell free to ask me, I will do my best to 20
answer all of your question. 21
In the next video, we will start to build our Web base network automation application. 22
Thankyou for watching and see you on the next video