Добавил release_date в Album

This commit is contained in:
Viner Abubakirov
2026-01-04 23:44:41 +05:00
parent 9d8f881b7a
commit 2e63f86484
4 changed files with 33 additions and 5 deletions

View File

@@ -17,11 +17,13 @@ class TrackListView(ListView):
def get_queryset(self):
return (
super().get_queryset()
.select_related("album", "album__artist")
.order_by("id")
super()
.get_queryset()
.select_related("album", "album__artist")
.order_by("id")
)
class ArtistListView(ListView):
model = Artist
template_name = "music/artist_list.html"
@@ -35,7 +37,14 @@ class ArtistListView(ListView):
class ArtistDetailView(django_views.View):
def get(self, request: HttpRequest, pk: int, *args, **kwargs):
artist = get_object_or_404(Artist, id=pk)
return render(request, "music/artist_detail.html", {"artist": artist})
return render(
request,
"music/artist_detail.html",
{
"artist": artist,
"albums": artist.albums.all().order_by("-release_date"),
},
)
class AlbumListView(ListView):