med/media/serializers.py

32 lines
973 B
Python

from rest_framework import serializers
from .models import Auteur, Emprunt, Jeu, Media
class AuteurSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Auteur
fields = ['url', 'name']
class MediaSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Media
fields = ['url', 'isbn', 'title', 'subtitle', 'external_url',
'side_identifier', 'authors', 'number_of_pages',
'publish_date']
class EmpruntSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Emprunt
fields = ['url', 'media', 'user', 'date_emprunt', 'date_rendu',
'permanencier_emprunt', 'permanencier_rendu']
class JeuSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Jeu
fields = ['url', 'name', 'proprietaire', 'duree', 'nombre_joueurs_min',
'nombre_joueurs_max', 'comment']