diff options
author | Frank Vanderham <twelve.eighty@gmail.com> | 2018-04-27 09:07:52 -0600 |
---|---|---|
committer | Jelle van der Waa <jelle@vdwaa.nl> | 2018-05-07 21:47:42 +0200 |
commit | e137256183d1ed10e43f417962614cbb2aa278bc (patch) | |
tree | b7c02a2a8c67dcae0ce104ec53b72ebf6e252715 | |
parent | b94a36e7c62fe9be8d35d0e85088798a28ba6d61 (diff) | |
download | archweb-e137256183d1ed10e43f417962614cbb2aa278bc.tar.gz archweb-e137256183d1ed10e43f417962614cbb2aa278bc.zip |
Remove calls to order_by() without parameters
Calls to order_by() without passing any parameters was causing
UnorderedObjectListWarning during unit tests. The failing unit tests
were testing the sitemap functionality. Sitemaps utilize Paginators,
which require either the entity ordering as specified in their Meta
object, or a specific ordering in the QuerySet, otherwise this warning
is issued.
-rw-r--r-- | packages/utils.py | 2 | ||||
-rw-r--r-- | sitemaps.py | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/packages/utils.py b/packages/utils.py index 86612d21..ccf5e1b5 100644 --- a/packages/utils.py +++ b/packages/utils.py @@ -78,7 +78,7 @@ def get_split_packages_info(): pkgnames = Package.objects.values('pkgname') split_pkgs = Package.objects.exclude(pkgname=F('pkgbase')).exclude( pkgbase__in=pkgnames).values('pkgbase', 'repo', 'arch').annotate( - last_update=Max('last_update')).order_by().distinct() + last_update=Max('last_update')).distinct() all_arches = Arch.objects.in_bulk({s['arch'] for s in split_pkgs}) all_repos = Repo.objects.in_bulk({s['repo'] for s in split_pkgs}) for split in split_pkgs: diff --git a/sitemaps.py b/sitemaps.py index 176d8b4f..33eb0064 100644 --- a/sitemaps.py +++ b/sitemaps.py @@ -16,7 +16,7 @@ class PackagesSitemap(Sitemap): return Package.objects.normal().only( 'pkgname', 'last_update', 'files_last_update', 'repo__name', 'repo__testing', 'repo__staging', - 'arch__name').order_by() + 'arch__name') def lastmod(self, obj): return obj.last_update @@ -81,7 +81,7 @@ class NewsSitemap(Sitemap): self.one_week_ago = now - timedelta(days=7) def items(self): - return News.objects.all().defer('content', 'guid', 'title').order_by() + return News.objects.all().defer('content', 'guid', 'title') def lastmod(self, obj): return obj.last_modified @@ -110,7 +110,7 @@ class ReleasesSitemap(Sitemap): changefreq = "monthly" def items(self): - return Release.objects.all().defer('info', 'torrent_data').order_by() + return Release.objects.all().defer('info', 'torrent_data') def lastmod(self, obj): return obj.last_modified @@ -129,7 +129,7 @@ class TodolistSitemap(Sitemap): self.two_weeks_ago = now - timedelta(days=14) def items(self): - return Todolist.objects.all().defer('raw').order_by() + return Todolist.objects.all().defer('raw').order_by('created') def lastmod(self, obj): return obj.last_modified |