Commit b0f18775 authored by fred's avatar fred

add distinct() to querysets creating first_diffusion, to avoid duplicates

parent 1c3d993e
...@@ -53,7 +53,7 @@ class EmissionMixin: ...@@ -53,7 +53,7 @@ class EmissionMixin:
FROM emissions_diffusion FROM emissions_diffusion
WHERE episode_id = emissions_episode.id)'''], WHERE episode_id = emissions_episode.id)'''],
tables=['emissions_diffusion'], tables=['emissions_diffusion'],
).order_by('-first_diffusion') ).order_by('-first_diffusion').distinct()
# get all related soundfiles in a single query # get all related soundfiles in a single query
soundfiles = {} soundfiles = {}
...@@ -422,7 +422,7 @@ class Home(TemplateView): ...@@ -422,7 +422,7 @@ class Home(TemplateView):
where=['''datetime = (SELECT MIN(datetime) where=['''datetime = (SELECT MIN(datetime)
FROM emissions_diffusion FROM emissions_diffusion
WHERE episode_id = emissions_episode.id)'''], WHERE episode_id = emissions_episode.id)'''],
tables=['emissions_diffusion'],).order_by('-first_diffusion') [:6] tables=['emissions_diffusion'],).order_by('-first_diffusion').distinct() [:6]
context['newsletter_form'] = SubscribeForm() context['newsletter_form'] = SubscribeForm()
...@@ -509,7 +509,7 @@ class Listen(TemplateView): ...@@ -509,7 +509,7 @@ class Listen(TemplateView):
where=['''datetime = (SELECT MIN(datetime) where=['''datetime = (SELECT MIN(datetime)
FROM emissions_diffusion FROM emissions_diffusion
WHERE episode_id = emissions_episode.id)'''], WHERE episode_id = emissions_episode.id)'''],
tables=['emissions_diffusion'],).order_by('-first_diffusion') [:10] tables=['emissions_diffusion'],).order_by('-first_diffusion').distinct() [:10]
context['categories'] = Category.objects.all() context['categories'] = Category.objects.all()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment