InfoTech-Backend/infotech/subjects/serializers.py

13 lines
428 B
Python
Raw Normal View History

2023-03-21 21:22:14 +08:00
from rest_framework import serializers
from django.contrib.auth.models import User
from .models import Subject
class SubjectSerializer(serializers.HyperlinkedModelSerializer):
enrolled_count = serializers.IntegerField(required=False, default=0)
class Meta:
model = Subject
fields = ('id', 'name', 'enrolled_count', 'max_slots', 'year_level')
read_only_fields = ('id', 'max_slots')