summaryrefslogtreecommitdiff
path: root/news/views.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-04-18 15:05:43 -0500
committerDan McGee <dan@archlinux.org>2012-05-02 09:37:46 -0500
commitbadc535aeb1d310a9b8aa59aade07045e6eae653 (patch)
treeaf644de8b034d45ba296ab39da93b359312a38ca /news/views.py
parentf3e0adcb2fc9a26e2ad9337a47550a37590074d9 (diff)
Ensure order_by default value is cleared when using distinct()
Otherwise the queryset returns nonsensical results. I find the design of this less than obvious but so be it; we can ensure the results work regardless of a default ordering on the model. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'news/views.py')
-rw-r--r--news/views.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/news/views.py b/news/views.py
index 268f0523..03f3b0ac 100644
--- a/news/views.py
+++ b/news/views.py
@@ -13,7 +13,8 @@ from .models import News
def find_unique_slug(newsitem):
'''Attempt to find a unique slug for this news item.'''
- existing = list(News.objects.values_list('slug', flat=True).distinct())
+ existing = list(News.objects.values_list(
+ 'slug', flat=True).order_by().distinct())
suffixed = slug = slugify(newsitem.title)
suffix = 0