i have a function that retrieve data from sql server database where i am 
using **fetchall()** then  for loop 
the retrieved data are all printed on the **cmd console** but when i tried 
to display these result on the template it **only display the last record**.

views.py
========
def search(request):

      query = cursor.execute('Select id, fullname from person')
      result = query.fetchall()
      for row in result:
        print("ID==>",id)
        IPD=row[0]
      return render(request,"test.html",{"IPD":IPD})

test.html
========

      {{ IPD }}

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/68025e0a-81cf-4e62-bd15-14e2006e0157%40googlegroups.com.

Reply via email to