1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2024-12-22 14:54:22 +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 176cfa698a
commit 13e7e4b97c

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