сделал удаление треков с плейлиста

This commit is contained in:
Mike0001-droid 2024-06-21 11:44:21 +05:00
parent 444728d661
commit e5b103151f
1 changed files with 13 additions and 0 deletions

View File

@ -70,6 +70,19 @@ class PlayListViewSet(GenericViewSet):
{'detail': 'Объекта не существует', 'error': {'PlayList': 'Объекта не существует'}},
status=status.HTTP_404_NOT_FOUND)
@action(detail=False, methods=['post'], schema=PlayListSchema())
def delete_song_with_playlist(self, request):
try:
song = Song.objects.get(azura_id=request.data.get('azura_id'))
item = PlayList.objects.get(user=request.user, pk=request.data.get('playlist_id'))
item.song.remove(song)
return Response({'detail': 'Объект удалён'}, status=status.HTTP_200_OK)
except ObjectDoesNotExist:
return Response(
{'detail': 'Объекта не существует', 'error': {'PlayList': 'Объекта не существует'}},
status=status.HTTP_404_NOT_FOUND)
@action(detail=False, methods=['post'], schema=PlayListSchema())
def add_to_playlist(self, request):
song = None