From 73df769a4a8e23f5dc3d44e748b191be6b59b6f8 Mon Sep 17 00:00:00 2001 From: keannu125 Date: Sat, 22 Apr 2023 17:07:14 +0800 Subject: [PATCH] Made schedules field in students not required --- .../0012_alter_student_schedules.py | 19 +++++++++++++++++++ infotech/students/serializers.py | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 infotech/students/migrations/0012_alter_student_schedules.py diff --git a/infotech/students/migrations/0012_alter_student_schedules.py b/infotech/students/migrations/0012_alter_student_schedules.py new file mode 100644 index 0000000..740dd09 --- /dev/null +++ b/infotech/students/migrations/0012_alter_student_schedules.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2 on 2023-04-22 08:08 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('schedules', '0007_schedule_semester'), + ('students', '0011_student_schedules'), + ] + + operations = [ + migrations.AlterField( + model_name='student', + name='schedules', + field=models.ManyToManyField(null=True, related_name='StudentSchedule_subject', through='schedules.StudentSchedule', to='schedules.schedule'), + ), + ] diff --git a/infotech/students/serializers.py b/infotech/students/serializers.py index a45f88e..49a1368 100644 --- a/infotech/students/serializers.py +++ b/infotech/students/serializers.py @@ -8,7 +8,7 @@ from subjects.models import Subject class StudentSerializer(serializers.HyperlinkedModelSerializer): schedules = serializers.SlugRelatedField( - queryset=Subject.objects.all(), many=True, slug_field='name', allow_null=True) + queryset=Subject.objects.all(), many=True, slug_field='name', allow_null=True, required=False) class Meta: model = Student