From 26b3dc5497e01c53f98ec7d47b64d08adf8259b9 Mon Sep 17 00:00:00 2001 From: Alexandr Karpov Date: Wed, 2 Nov 2022 14:32:46 +0300 Subject: [PATCH] bug fixes --- image_markuper/dicom/api/serializers.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/image_markuper/dicom/api/serializers.py b/image_markuper/dicom/api/serializers.py index 81779dd..b64aac5 100644 --- a/image_markuper/dicom/api/serializers.py +++ b/image_markuper/dicom/api/serializers.py @@ -165,11 +165,15 @@ class ListProjectSerializer(serializers.ModelSerializer): class Meta: model = Project - fields = ["url", "created"] + fields = ["slug", "url", "created"] extra_kwargs = { + "slug": {"read_only": True}, "created": {"read_only": True}, } + def create(self, validated_data): + return Project.objects.create(user=self.context["request"].user) + class ProjectSerializer(serializers.ModelSerializer): files = ListDicomSerializer(many=True) @@ -177,3 +181,6 @@ class ProjectSerializer(serializers.ModelSerializer): class Meta: model = Project fields = ["files", "slug", "created"] + + def create(self, validated_data): + return Project.objects.create(user=self.context["request"].user)