InfoTech-Backend/infotech/students/serializers.py

20 lines
824 B
Python

from rest_framework import serializers
from django.contrib.auth.models import User
from .models import Student
from schedules.models import Schedule
class StudentSerializer(serializers.HyperlinkedModelSerializer):
schedules = serializers.SlugRelatedField(
queryset=Schedule.objects.all(), slug_field='schedule_subject', allow_null=True)
class Meta:
model = Student
fields = ['id', 'full_name', 'first_name', 'middle_name', 'last_name',
'age', 'sex', 'birthdate',
'address', 'birthplace',
'mother_name', 'father_name',
'registrar_done', 'clearance_done', 'pta_done',
'schedules', 'year_level', 'current_semester'
]
read_only_fields = ['id', 'full_name']