Created
May 28, 2019 18:46
-
-
Save rudmanmrrod/29aa114e5004e387434c1f430fc481e5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework import viewsets, status | |
from rest_framework.response import Response | |
from .models import * | |
from .serializers import * | |
class CancionesForAlbumViewSet(viewsets.ModelViewSet): | |
"""! | |
Vistas para registrar las canciones de un album | |
@author Rodrigo Boet (rudmanmrrod at gmail.com) | |
@date 28-05-2019 | |
@version 1.0.0 | |
""" | |
model = Canciones | |
queryset = Canciones.objects.all() | |
serializer_class = CancionesSolasSerializer | |
def get_queryset(self): | |
queryset = Canciones.objects.filter(album_id=self.kwargs['id']).all() | |
return queryset | |
def create(self, request, id): | |
request.data['album_id'] = id | |
serializer = self.get_serializer(data=request.data) | |
serializer.is_valid(raise_exception=True) | |
serializer.save() | |
return Response(serializer.data, status=status.HTTP_201_CREATED) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment