diff options
author | Mike Chen <chagel@gmail.com> | 2009-08-24 00:15:54 +0800 |
---|---|---|
committer | Mike Chen <chagel@gmail.com> | 2009-08-24 00:15:54 +0800 |
commit | 6fd182d3e65e8edc2a63e5823ef077314c00d9e5 (patch) | |
tree | ec7ac1deaddf17a95a5694359a339acfa0f1c756 /forum | |
parent | 9dfa77161d0e76ef7db779d570c73547783a1813 (diff) | |
download | askbot-6fd182d3e65e8edc2a63e5823ef077314c00d9e5.tar.gz askbot-6fd182d3e65e8edc2a63e5823ef077314c00d9e5.tar.bz2 askbot-6fd182d3e65e8edc2a63e5823ef077314c00d9e5.zip |
fix tags sort bug
Diffstat (limited to 'forum')
-rw-r--r-- | forum/views.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/forum/views.py b/forum/views.py index 0d2b3ca2..dc38bcdf 100644 --- a/forum/views.py +++ b/forum/views.py @@ -710,14 +710,14 @@ def tags(request): if request.method == "GET": stag = request.GET.get("q", "").strip() - if stag is not None: + if len(stag) > 0: objects_list = Paginator(Tag.objects.filter(deleted=False).exclude(used_count=0).extra(where=['name like %s'], params=['%' + stag + '%']), DEFAULT_PAGE_SIZE) else: - if sortby == "name": - objects_list = Paginator(Tag.objects.all().filter(deleted=False).exclude(used_count=0).order_by("name"), DEFAULT_PAGE_SIZE) + if sortby == "used": + sortby = "-used_count" else: - objects_list = Paginator(Tag.objects.all().filter(deleted=False).exclude(used_count=0).order_by("-used_count"), DEFAULT_PAGE_SIZE) - + sortby = "name" + objects_list = Paginator(Tag.objects.all().filter(deleted=False).exclude(used_count=0).order_by(sortby), DEFAULT_PAGE_SIZE) try: tags = objects_list.page(page) except (EmptyPage, InvalidPage): |