Hi All, I am using raw sql to connect to database. The reason we used raw sql instead of the Django model is because the database is legacy and is being shared by multiple applications...
I have one use case that I'm struggling right now. Basically I have a page that fetch more than 1000 results. My query is like this: cursor = connection.cursor() cursor.execute(''' SELECT br.id, br.name, br.created_at, br.updated_at, br.branchpoint_str, br.source FROM branches as br LEFT JOIN branches_projects as bp ON br.id = bp.branch_id WHERE bp.project_id = "%s" AND source != "other" ORDER BY updated_at DESC ''', [int(project_id)] ) Then in my template, I have this: {% for br in special_branches %} <tr class="{% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %} highlightable" link="/files/{{build.image_path}}/build{{build.build_number}}/"> <td class="selectable">{{br.name}}</td> <td class="selectable">{{br.branchpoint}}</td> <td class="selectable center">{{ br.source|upper }}</td> <td class="selectable center">{{br.updated_at}} <td class="selectable center">{{br.built_at}}</td> </tr> {% endfor %} The current problem is this would create a very long page... I am wondering how to approach this problem so that I can have different page on the template, and say 100 result per page, when i click the second page, then django will fetch result 100-200. Thanks! -- 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 post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f6a3df97-8218-4fb8-b200-f4535797e135%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.