Item create: 404 if collection isn't found.

It doesn't actually change anything beacuse it 404s in the
collection getting, but still, good to have this here too.
This commit is contained in:
Tom Hacohen 2020-02-26 14:20:23 +02:00
parent cc00391504
commit d6df94facf

View File

@ -121,7 +121,7 @@ class CollectionItemViewSet(BaseViewSet):
return queryset return queryset
def create(self, request, collection_uid=None): def create(self, request, collection_uid=None):
collection_object = self.get_collection_queryset(Collection.objects).get(uid=collection_uid) collection_object = get_object_or_404(self.get_collection_queryset(Collection.objects), uid=collection_uid)
many = isinstance(request.data, list) many = isinstance(request.data, list)
serializer = self.serializer_class(data=request.data, many=many) serializer = self.serializer_class(data=request.data, many=many)