InfoTech-Backend/infotech/students/serializers.py

23 lines
896 B
Python
Raw Normal View History

2023-04-22 14:14:53 +08:00
from django.shortcuts import get_object_or_404
2023-03-21 21:49:26 +08:00
from rest_framework import serializers
from django.contrib.auth.models import User
from .models import Student
2023-04-22 11:59:16 +08:00
from schedules.models import Schedule
2023-04-22 14:14:53 +08:00
from subjects.models import Subject
2023-03-21 21:49:26 +08:00
class StudentSerializer(serializers.HyperlinkedModelSerializer):
2023-04-22 13:42:09 +08:00
schedules = serializers.SlugRelatedField(
2023-04-22 14:14:53 +08:00
queryset=Subject.objects.all(), slug_field='name', allow_null=True)
2023-03-21 21:49:26 +08:00
class Meta:
model = Student
fields = ['id', 'full_name', 'first_name', 'middle_name', 'last_name',
2023-03-21 21:49:26 +08:00
'age', 'sex', 'birthdate',
'address', 'birthplace',
'mother_name', 'father_name',
'registrar_done', 'clearance_done', 'pta_done',
2023-04-22 13:42:09 +08:00
'schedules', 'year_level', 'current_semester'
2023-03-21 21:49:26 +08:00
]
read_only_fields = ['id', 'full_name']