Search code examples
pythondjangopythonanywhere

where am I being limited?


I have this piece of code in my views.py for a django app:

for i in range(0,10):
    row = cursor.fetchone()
    tablestring = tablestring + "<tr><td>" + row[0] + "</td><td>" + + str(row[3]) + "</td></tr>"

This works fine when I load the page but if I change the range to (0,20) or anything higher, I just get a blank page. My question is: what is causing this limitation? Is it something with python or django or with the host (pythonanywhere)?

Also, I'm just starting with django and I understand this may not be the best code. If you have any suggestions to make it neater or more efficient they would be appreciated.

Thanks for the help

Edit: here is my query:

cursor.execute("""SELECT title, movie_url, movie_id, cScore  FROM movies""")

Solution

  • you should really use django orm and write those table markups in a template, follow this tutorial to get the basic concepts