Want to show variables

18 views
Skip to first unread message

Rohit Lohar

unread,
Jul 5, 2022, 12:59:56 AM7/5/22
to Django users
I want to access the data from the model but specific data 

like I am writing the code in python below i want it to implement in django template
and model used is grade

for i in range(1,20):
      c = "metalc"+str(i)
      n = "metaln" + str(i)
      if(grade.c!=0 and grade.n!=0)
              {{ grade.c }} {{ grade.n }}


like this

Mr.Teapot

unread,
Jul 5, 2022, 1:04:15 AM7/5/22
to Django users
Hi,
You can use custom template tag. More details in Django docs https://docs.djangoproject.com/en/4.0/howto/custom-template-tags/.
Reply all
Reply to author
Forward
0 new messages