mirror of
https://github.com/lemeow125/StudE-Backend.git
synced 2024-11-17 14:29:25 +08:00
15 lines
480 B
Python
15 lines
480 B
Python
from rest_framework import serializers
|
|
from .models import StudentStatus
|
|
|
|
|
|
class StudentStatusSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = StudentStatus
|
|
fields = '__all__'
|
|
read_only_fields = ('user',)
|
|
|
|
def create(self, validated_data):
|
|
user = self.context['request'].user
|
|
student_status, created = StudentStatus.objects.update_or_create(
|
|
user=user, defaults=validated_data)
|
|
return student_status
|