X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/4bacdff72c8044d25066ff95719543a763844e11..eeb6424401e4ab36f9bcdb017b36b2957a4e06f2:/src/catalogue/api/views.py diff --git a/src/catalogue/api/views.py b/src/catalogue/api/views.py index c69c246ad..a4653d12f 100644 --- a/src/catalogue/api/views.py +++ b/src/catalogue/api/views.py @@ -331,6 +331,7 @@ class TagView(RetrieveAPIView): def post(self, request, **kwargs): data = json.loads(request.POST.get('data')) fields = { + "name_pl": "name_pl", "description_pl": "description_pl", "plural": "plural", "is_epoch_specific": "genre_epoch_specific", @@ -341,7 +342,10 @@ class TagView(RetrieveAPIView): obj = self.get_object() for data_field, model_field in fields.items(): setattr(obj, model_field, data.get(data_field, getattr(obj, model_field))) - obj.save(update_fields=fields.values(), quick=True) + if obj.pk: + obj.save(update_fields=fields.values(), quick=True) + else: + obj.save() return Response({})