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.
-------- Original message --------
From: Kushal Neupane <mkushal10@gmail.com>
Date: 30/04/2020 16:20 (GMT+03:00)
To: Django users <django-users@googlegroups.com>
Subject: How to count total number of student to display in template
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.
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+unsubscribe@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.
No comments:
Post a Comment