23 lines
876 B
Python
23 lines
876 B
Python
from itertools import permutations
|
|
from rest_framework.views import APIView
|
|
from rest_framework.response import Response
|
|
from rest_framework.authentication import SessionAuthentication
|
|
from rest_framework.permissions import IsAuthenticated
|
|
from playlist.models import Artist
|
|
from playlist.serializers import ArtistSerializer
|
|
|
|
class ArtistListView(APIView):
|
|
authentication_classes = [SessionAuthentication]
|
|
permission_classes = [IsAuthenticated]
|
|
|
|
def get(self, request):
|
|
artists = Artist.objects.all()
|
|
serializer = ArtistSerializer(artists, many=True, context={'request': request})
|
|
return Response(serializer.data)
|
|
|
|
class ArtistDetailView(APIView):
|
|
def get(self, request, id):
|
|
artist = Artist.objects.get(pk=id)
|
|
serializer = ArtistSerializer(artist, context={'request': request})
|
|
return Response(serializer.data)
|