summaryrefslogtreecommitdiff
path: root/tbc
diff options
context:
space:
mode:
authorhardythe12014-09-30 17:28:00 +0530
committerhardythe12014-09-30 17:28:00 +0530
commitc12f4b2715b56f8ccbdf2ace70ba584b72dc1dce (patch)
tree62f40c0d89c7863d9b20ca657f9cc408fda73f7e /tbc
parent9cad9cc2d00e8efa73cf0e501ba7973a3d807fe5 (diff)
downloadPython-TBC-Interface-c12f4b2715b56f8ccbdf2ace70ba584b72dc1dce.tar.gz
Python-TBC-Interface-c12f4b2715b56f8ccbdf2ace70ba584b72dc1dce.tar.bz2
Python-TBC-Interface-c12f4b2715b56f8ccbdf2ace70ba584b72dc1dce.zip
trying to implement natural sorting
Diffstat (limited to 'tbc')
-rwxr-xr-xtbc/views.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/tbc/views.py b/tbc/views.py
index 5167978..21f059c 100755
--- a/tbc/views.py
+++ b/tbc/views.py
@@ -451,7 +451,8 @@ def BookDetails(request, book_id=None):
else:
context['user'] = request.user
book = Book.objects.get(id=book_id)
- chapters = Chapters.objects.filter(book=book).order_by('name','pk')
+ query = 'SELECT * from tbc_chapters where book_id = (SELECT id from tbc_book where id='+book_id+') ORDER BY LENGTH(name), name;'
+ chapters = Chapters.objects.raw(query)
images = ScreenShots.objects.filter(book=book)
context['chapters'] = chapters
context['images'] = images
@@ -464,7 +465,8 @@ def BookReview(request, book_id=None):
if is_reviewer(request.user):
if book_id:
book = Book.objects.get(id=book_id)
- chapters = Chapters.objects.filter(book=book).order_by('id')
+ query = 'SELECT * from tbc_chapters where book_id = (SELECT id from tbc_book where id='+book_id+') ORDER BY LENGTH(name), name;'
+ chapters = Chapters.objects.raw(query)
images = ScreenShots.objects.filter(book=book)
context['chapters'] = chapters
context['images'] = images