Order news in search results
This commit is contained in:
parent
b56829accc
commit
ebf31f8492
|
|
@ -31,6 +31,10 @@ class NewsType(models.Model):
|
||||||
class NewsQuerySet(TranslationQuerysetMixin):
|
class NewsQuerySet(TranslationQuerysetMixin):
|
||||||
"""QuerySet for model News"""
|
"""QuerySet for model News"""
|
||||||
|
|
||||||
|
def sort_by_start(self):
|
||||||
|
"""Return qs sorted by start DESC"""
|
||||||
|
return self.order_by('-start')
|
||||||
|
|
||||||
def rating_value(self):
|
def rating_value(self):
|
||||||
return self.annotate(rating=models.Count('ratings__ip', distinct=True))
|
return self.annotate(rating=models.Count('ratings__ip', distinct=True))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ class NewsDocument(Document):
|
||||||
related_models = [models.NewsType]
|
related_models = [models.NewsType]
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return super().get_queryset().published().with_base_related()
|
return super().get_queryset().published().with_base_related().sort_by_start()
|
||||||
|
|
||||||
def get_instances_from_related(self, related_instance):
|
def get_instances_from_related(self, related_instance):
|
||||||
"""If related_models is set, define how to retrieve the Car instance(s) from the related model.
|
"""If related_models is set, define how to retrieve the Car instance(s) from the related model.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user