Actually have this model:
class MusicFile(models.Model):
file = models.FileField(upload_to="files")
def exist_in_playlist(self, playlist_id):
exist = False
try:
mp = PlayList.objects.get(id=playlist_id, items__id=self.id)
exist = True
except PlayList.DoesNotExist:
pass
return exist
class PlayList(models.Model):
items = ManyToManyField(MusicFile)
MusicFile.exist_in_playlist
returns me if X MusicFile is in Y Playlist.
With django do I have the option to write something like
PlayList.items.exist(MusicFile)
?If not, Is this a good implementation for search if a MusicFile is in the PlayList?
Thanks.