Queryset methods for playlists
This commit is contained in:
parent
e31099ef33
commit
7e9320fc1c
|
@ -9,6 +9,12 @@ from funkwhale_api.common import fields
|
|||
from funkwhale_api.common import preferences
|
||||
|
||||
|
||||
class PlaylistQuerySet(models.QuerySet):
|
||||
def with_tracks_count(self):
|
||||
return self.annotate(
|
||||
_tracks_count=models.Count('playlist_tracks'))
|
||||
|
||||
|
||||
class Playlist(models.Model):
|
||||
name = models.CharField(max_length=50)
|
||||
user = models.ForeignKey(
|
||||
|
@ -18,6 +24,8 @@ class Playlist(models.Model):
|
|||
auto_now=True)
|
||||
privacy_level = fields.get_privacy_field()
|
||||
|
||||
objects = PlaylistQuerySet.as_manager()
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
|
|
Loading…
Reference in New Issue