From badc535aeb1d310a9b8aa59aade07045e6eae653 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 18 Apr 2012 15:05:43 -0500 Subject: 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 --- news/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'news') diff --git a/news/views.py b/news/views.py index 268f052..03f3b0a 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 -- cgit v1.2.3-24-g4f1b