fixes for author box
[wolnelektury.git] / src / catalogue / api / views.py
index c69c246..a4653d1 100644 (file)
@@ -331,6 +331,7 @@ class TagView(RetrieveAPIView):
     def post(self, request, **kwargs):
         data = json.loads(request.POST.get('data'))
         fields = {
     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",
             "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 = 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({})
 
 
         return Response({})