Hi, Convert the variable IPD into an array or render result variable on template
On Fri, 11 Oct 2019 at 12:04, leb dev <[email protected]> wrote: > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/68025e0a-81cf-4e62-bd15-14e2006e0157%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/68025e0a-81cf-4e62-bd15-14e2006e0157%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- Thanks & Regards, Raja Sekar Sampath +91 9087434567. -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAAS5AE6gvtL%2Br5G6Oj2-FW9vUFY3C6PLA31MJ_mGewABNTJ0pg%40mail.gmail.com.

