serializers.py 638 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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):
    class Meta:
        model = OpenTime

class ScheduleSerializer(serializers.ModelSerializer):
    open_times = OpenTimeSerializer(many=True)

    class Meta:
        model = Schedule

class FacilitySerializer(serializers.ModelSerializer):
    main_schedule = ScheduleSerializer()
    special_schedules = ScheduleSerializer(many=True)

    class Meta:
        model = Facility