Skip to content

Commit

Permalink
query optimization on Work
Browse files Browse the repository at this point in the history
  • Loading branch information
jakosexy committed Aug 5, 2018
1 parent 0f6c49d commit 6a3ca2a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions music_publisher/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,14 @@ def duration(self, obj):
'work_id', 'title', 'iswc', 'writer_last_names',
'percentage_controlled', 'duration', 'isrc', 'album_cd', '_cwr')

def get_queryset(self, request):
qs = super().get_queryset(request)
qs = qs.prefetch_related('writerinwork_set')
qs = qs.prefetch_related('writers')
qs = qs.prefetch_related('firstrecording__album_cd')
return qs


class HasISRCListFilter(admin.SimpleListFilter):
title = 'Has ISWC'
parameter_name = 'has_iswc'
Expand Down

0 comments on commit 6a3ca2a

Please sign in to comment.