X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/20624793bdba58ffac438d836c94d09d65f6acd7..c6537f136f4ec0230f5e7c71dd1abf9616151a47:/src/catalogue/api/views.py diff --git a/src/catalogue/api/views.py b/src/catalogue/api/views.py index 1af1577e7..b45ad4656 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.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'))