add related articles to detail views

This commit is contained in:
Tobias Brunner 2025-06-06 15:22:02 +02:00
parent b456816035
commit 18e9156683
Signed by: tobru
SSH key fingerprint: SHA256:kOXg1R6c11XW3/Pt9dbLdQvOJGFAy+B2K6v6PtRWBGQ
8 changed files with 140 additions and 0 deletions

View file

@ -153,7 +153,13 @@ def service_detail(request, slug):
slug=slug,
)
# Get related articles for this service
related_articles = service.articles.filter(is_published=True).order_by(
"-created_at"
)[:3]
context = {
"service": service,
"related_articles": related_articles,
}
return render(request, "services/service_detail.html", context)