From e71884a7f3da412fdd2e993fe34e1bddd34b035a Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 11 Oct 2021 19:24:44 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Make=20POST=20requests=20return?= =?UTF-8?q?=20all=20fields=20on=20creation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/sophon/core/models.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/sophon/core/models.py b/backend/sophon/core/models.py index 20b6b90..71fe901 100644 --- a/backend/sophon/core/models.py +++ b/backend/sophon/core/models.py @@ -4,13 +4,15 @@ properly. """ from __future__ import annotations -import typing + import abc +import typing import pkg_resources -from django.db import models from django.contrib.auth.models import User +from django.db import models from rest_framework.serializers import ModelSerializer + from sophon.core.enums import SophonGroupAccess @@ -154,7 +156,8 @@ class SophonModel(models.Model): class CreateSerializer(ModelSerializer): class Meta: model = cls - fields = list(cls.get_creation_fields()) + fields = list(cls.get_fields().union(cls.get_creation_fields())) + read_only_fields = list(cls.get_fields().difference(cls.get_creation_fields())) return CreateSerializer