Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2021 Release #2

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
2021 Order homepage entries by name
PeterGrand committed Dec 5, 2021
commit 95013e5b57886b688941410aa8502190da2ad8a3
4 changes: 3 additions & 1 deletion gingerhouse/houses/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from random import shuffle

from django.db.models import OuterRef, Subquery, ImageField
from django.shortcuts import redirect, reverse
from django.views.generic import ListView, DetailView, FormView
@@ -12,7 +14,7 @@ class HousesListView(ListView):
template_name = 'houses/index.html'

def get_queryset(self):
qs = super().get_queryset()
qs = super().get_queryset().order_by('name')
qs = qs.annotate(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

image=Subquery(Photo.objects.filter(house=OuterRef("id"), is_primary=True)[:1].values("image"),
output_field=ImageField())