X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/20624793bdba58ffac438d836c94d09d65f6acd7..739f55be14e161e485b2107b628689c4f01ded6b:/src/catalogue/api/views.py diff --git a/src/catalogue/api/views.py b/src/catalogue/api/views.py index 1af1577e7..5512501c6 100644 --- a/src/catalogue/api/views.py +++ b/src/catalogue/api/views.py @@ -313,11 +313,20 @@ class TagView(RetrieveAPIView): queryset = Tag.objects.all() def get_object(self): - return get_object_or_404( - Tag, - category=self.kwargs['category'], - slug=self.kwargs['slug'] - ) + try: + return get_object_or_404( + Tag, + category=self.kwargs['category'], + slug=self.kwargs['slug'] + ) + except Http404: + if self.request.method == 'PUT': + return Tag( + category=self.kwargs['category'], + slug=self.kwargs['slug'] + ) + else: + raise def post(self, request, **kwargs): data = json.loads(request.POST.get('data'))