cineclub-site/server/myapi/serializers.py

18 lines
538 B
Python

from rest_framework import serializers
from .models import Film
class MoreFieldsModelSerializer(serializers.ModelSerializer):
def get_field_names(self, declared_fields, info):
expanded_fields = super().get_field_names(declared_fields, info)
if getattr(self.Meta, "extra_fields", None):
return expanded_fields + self.Meta.extra_fields
else:
return expanded_fields
class FilmSerializer(serializers.ModelSerializer):
class Meta:
model = Film
fields = "__all__" #