serializers.py 763 Bytes
Newer Older
1
2
3
4
5
6
7
8
from rest_framework import serializers
from website.models import Category, Facility, Schedule, OpenTime

class CategorySerializer(serializers.ModelSerializer):
    class Meta:
        model = Category

class OpenTimeSerializer(serializers.ModelSerializer):
9
    schedule = serializers.RelatedField(many=False)
10
11
12
13
    class Meta:
        model = OpenTime

class ScheduleSerializer(serializers.ModelSerializer):
14
    open_times = OpenTimeSerializer(many=True)
15
16
17
18
    class Meta:
        model = Schedule

class FacilitySerializer(serializers.ModelSerializer):
19
20
21
    category = serializers.RelatedField(many=False)
    main_schedule = serializers.RelatedField(many=False)
    special_schedules = serializers.RelatedField(many=True)
22
23
24
25

    class Meta:
        model = Facility