cineclub-site/server/myapi/serializers.py

20 lines
539 B
Python
Raw Normal View History

2022-04-03 01:20:53 +02:00
from rest_framework import serializers
from .models import Film
2022-04-03 01:20:54 +02:00
2022-07-13 02:18:06 +02:00
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
2022-04-03 01:20:55 +02:00
class FilmSerializer(serializers.ModelSerializer):
2022-04-03 01:20:53 +02:00
class Meta:
model = Film
2022-04-03 01:20:55 +02:00
fields = "__all__" #