From 2861c856af44a0fa948fe6e6513b6b1047ccdc55 Mon Sep 17 00:00:00 2001 From: Mark Hoekveen Date: Mon, 26 Feb 2024 21:31:04 +0100 Subject: [PATCH] Ordered artists on overview --- playlist/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/playlist/views.py b/playlist/views.py index 98a4721..015ccc0 100644 --- a/playlist/views.py +++ b/playlist/views.py @@ -4,6 +4,7 @@ from django.http import HttpResponse, HttpResponseRedirect from django.template.response import TemplateResponse from django.contrib.auth.mixins import LoginRequiredMixin import re +from collections import OrderedDict from .models import Track, Artist, Album, Vote, Background, Profile from .utils import from_json, get_unvoted from . import spotify @@ -170,7 +171,9 @@ class OverView(LoginRequiredMixin, View): if not artists[artist.name].get(vote.track.album.name): artists[artist.name][vote.track.album.name] = [] artists[artist.name][vote.track.album.name] += [vote.track] + artists_ordered = OrderedDict(sorted(artists.items())) + context = { - "artists": artists + "artists": artists_ordered } return TemplateResponse(request, "Overview.html", context) \ No newline at end of file