Skip to content

Commit

Permalink
ProfileSerializer removed first_name and last_name from read_only_fields
Browse files Browse the repository at this point in the history
  • Loading branch information
michalmasrna1 committed Nov 23, 2024
1 parent ba7b777 commit b9ba5cc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions personal/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': {
Expand Down Expand Up @@ -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']
Expand Down

0 comments on commit b9ba5cc

Please sign in to comment.