Advertisement
muhammad_nasif

Untitled

Dec 11th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. def sort_descending(request):
  2.  
  3. sql = ""
  4. cursor = connection.cursor()
  5. cursor.execute(sql)
  6. result_search = cursor.fetchall()
  7. cursor.close()
  8. print(result_search)
  9. table = []
  10. for i in result_search:
  11. product_id = i[0]
  12. name = i[1]
  13. type = i[2]
  14. price = i[3]
  15. stock = i[4]
  16. warranty = i[5]
  17. row = {'product_id': product_id, 'name': name, 'type': type, 'warranty': warranty, 'price': price}
  18. table.append(row)
  19. print(table)
  20. return render(request, 'home.html', {'table': table})
  21.  
  22.  
  23. def sort_ascending(request):
  24. sql = ""
  25. cursor = connection.cursor()
  26. cursor.execute(sql)
  27. result_search = cursor.fetchall()
  28. cursor.close()
  29. print(result_search)
  30. table = []
  31. for i in result_search:
  32. product_id = i[0]
  33. name = i[1]
  34. type = i[2]
  35. price = i[3]
  36. stock = i[4]
  37. warranty = i[5]
  38. row = {'product_id': product_id, 'name': name, 'type': type, 'warranty': warranty, 'price': price}
  39. table.append(row)
  40. print(table)
  41. return render(request, 'home.html', {'table': table})
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement