diff --git a/personal/serializers.py b/personal/serializers.py index 3d38ab2..a209657 100644 --- a/personal/serializers.py +++ b/personal/serializers.py @@ -73,8 +73,8 @@ class Meta: fields = ['grade_name', 'id', 'email', 'first_name', 'last_name', 'school', 'phone', 'parent_phone', 'grade', 'is_student', 'has_school', 'school_id', 'verbose_name'] - read_only_fields = ['grade_name', 'id', 'first_name', 'last_name', - 'email', 'is_student', 'has_school', 'school', 'verbose_name'] + read_only_fields = ['grade_name', 'id', 'email', + 'is_student', 'has_school', 'school', 'verbose_name'] extra_kwargs = { 'grade': { @@ -112,10 +112,11 @@ def update(self, instance, validated_data): def create(self, validated_data): grade = Grade.objects.get(pk=validated_data['grade']) + school = School.objects.get(pk=validated_data['school_id']) return Profile.objects.create( first_name=validated_data['first_name'], last_name=validated_data['last_name'], - school=validated_data['school'], + school=school, year_of_graduation=grade.get_year_of_graduation_by_date(), phone=validated_data['phone'], parent_phone=validated_data['parent_phone']