1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2024-12-22 23:04:21 +00:00

🐛 Make POST requests return all fields on creation

This commit is contained in:
Steffo 2021-10-11 19:24:44 +02:00
parent ebc6a02206
commit e71884a7f3
Signed by: steffo
GPG key ID: 6965406171929D01

View file

@ -4,13 +4,15 @@ properly.
""" """
from __future__ import annotations from __future__ import annotations
import typing
import abc import abc
import typing
import pkg_resources import pkg_resources
from django.db import models
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.db import models
from rest_framework.serializers import ModelSerializer from rest_framework.serializers import ModelSerializer
from sophon.core.enums import SophonGroupAccess from sophon.core.enums import SophonGroupAccess
@ -154,7 +156,8 @@ class SophonModel(models.Model):
class CreateSerializer(ModelSerializer): class CreateSerializer(ModelSerializer):
class Meta: class Meta:
model = cls 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 return CreateSerializer