How to count total number of student to display in template

20 views
Skip to first unread message

Kushal Neupane

unread,
Apr 30, 2020, 9:19:56 AM4/30/20
to Django users
The following are  the models and template where i wnat to display the count. The displayed is static. Now, i wanna make dynamic. Thank you. Help me.



lumwakapuku

unread,
Apr 30, 2020, 9:44:03 AM4/30/20
to django...@googlegroups.com
In you are view create a function 
Eg 
def student():
       student = Student.objects.all()
       Tt_student = student.count()
        Context = { "student":student, "Tt_student":Tt_student }
        Return render(request, "your templete here", context)

In you templete render it as 
{{ Tt_student  }}



Sent from Samsung tablet.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3691ca10-2ed3-466e-a2ee-7d1c1947701c%40googlegroups.com.

Kushal Neupane

unread,
Apr 30, 2020, 9:45:02 AM4/30/20
to django...@googlegroups.com
Thank you sir.😊

lumwakapuku

unread,
Apr 30, 2020, 9:55:07 AM4/30/20
to django...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages