X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/20624793bdba58ffac438d836c94d09d65f6acd7..5bd864493e531e5600c5ca989825d89cc3ee1487:/src/catalogue/api/views.py?ds=sidebyside 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'))