diff --git a/api/serializers.py b/api/serializers.py index e0af85a..6f267e9 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -87,6 +87,7 @@ def create(self, validated_data): table_data = validated_data.pop("courses_data") collection = Collection.objects.create(**validated_data) + # First nested list will have first period of each day course_list = defaultdict(list) for order, periods in enumerate(table_data, 1): for day, period in enumerate(periods, 1): diff --git a/api/views.py b/api/views.py index 0eb1553..c23cce5 100644 --- a/api/views.py +++ b/api/views.py @@ -107,7 +107,8 @@ def get(self, request): schedules = Schedule.objects.filter(course__collection__user=request.user) max_order = schedules.aggregate(Max("order", default=1))["order__max"] - template = [[None] * max_order for i in range(5)] + # First nested list is the first period of each day, second nested list is second period of each day + template = [[""] * 5 for i in range(max_order)] for day in range(0, 5): schedules_on_day = schedules.filter(day_of_week=day + 1).order_by("order")