from .models import Course,Registration
from rest_framework import serializers

from course.models import Course
from users.serializer import UserSerializer
class CourseSerializer(serializers.ModelSerializer):
    c_teacher = UserSerializer()
    class Meta:
        model = Course
        fields = (
            'c_id',
            'c_code',
            'c_name',
            'c_teacher',
            'cnt_sign'
        )

class RegistrationSerializer(serializers.ModelSerializer):
    user = UserSerializer()
    course = CourseSerializer()
    class Meta:
        model = Registration
        fields = (
            'user',
            'course',
            'cnt_abcense',
        )


class RegistrationSerializerByCourse(serializers.ModelSerializer):
    user = UserSerializer()
    # course = CourseSerializer()
    class Meta:
        model = Registration
        fields = (
            'user',
            # 'course',
            'cnt_abcense',
        )

class RegistrationSerializerByUser(serializers.ModelSerializer):
    #user = UserSerializer()
    course = CourseSerializer()
    class Meta:
        model = Registration
        fields = (
            #'user',
            'course',
            'cnt_abcense',
        )

class RegistrationSerializer1(serializers.ModelSerializer):
    c_teacher = UserSerializer()
    student= serializers.SerializerMethodField()

    def get_student(self, obj):
        result_set = Registration.objects.filter(course=obj) 
        return RegistrationSerializer(result_set, many=True).data

    class Meta:
        model = Course
        fields = (
            'c_id',
            'c_name',
            'c_code',
            'c_teacher',
            'cnt_sign',
            'student',
        )
    
d8327e8a3fc3c303e797e51d44c8f7ce46b44e5f
<mask token>


class RegistrationSerializer1(serializers.ModelSerializer):
    c_teacher = UserSerializer()
    student = serializers.SerializerMethodField()

    def get_student(self, obj):
        result_set = Registration.objects.filter(course=obj)
        return RegistrationSerializer(result_set, many=True).data


    class Meta:
        model = Course
        fields = 'c_id', 'c_name', 'c_code', 'c_teacher', 'cnt_sign', 'student'

<mask token>


class RegistrationSerializer(serializers.ModelSerializer):
    <mask token>
    <mask token>


    class Meta:
        model = Registration
        fields = 'user', 'course', 'cnt_abcense'


class RegistrationSerializerByCourse(serializers.ModelSerializer):
    user = UserSerializer()


    class Meta:
        model = Registration
        fields = 'user', 'cnt_abcense'


class RegistrationSerializerByUser(serializers.ModelSerializer):
    course = CourseSerializer()


    class Meta:
        model = Registration
        fields = 'course', 'cnt_abcense'


class RegistrationSerializer1(serializers.ModelSerializer):
    c_teacher = UserSerializer()
    student = serializers.SerializerMethodField()

    def get_student(self, obj):
        result_set = Registration.objects.filter(course=obj)
        return RegistrationSerializer(result_set, many=True).data


    class Meta:
        model = Course
        fields = 'c_id', 'c_name', 'c_code', 'c_teacher', 'cnt_sign', 'student'

<mask token>


class CourseSerializer(serializers.ModelSerializer):
    <mask token>


    class Meta:
        model = Course
        fields = 'c_id', 'c_code', 'c_name', 'c_teacher', 'cnt_sign'


class RegistrationSerializer(serializers.ModelSerializer):
    user = UserSerializer()
    course = CourseSerializer()


    class Meta:
        model = Registration
        fields = 'user', 'course', 'cnt_abcense'


class RegistrationSerializerByCourse(serializers.ModelSerializer):
    user = UserSerializer()


    class Meta:
        model = Registration
        fields = 'user', 'cnt_abcense'


class RegistrationSerializerByUser(serializers.ModelSerializer):
    course = CourseSerializer()


    class Meta:
        model = Registration
        fields = 'course', 'cnt_abcense'


class RegistrationSerializer1(serializers.ModelSerializer):
    c_teacher = UserSerializer()
    student = serializers.SerializerMethodField()

    def get_student(self, obj):
        result_set = Registration.objects.filter(course=obj)
        return RegistrationSerializer(result_set, many=True).data


    class Meta:
        model = Course
        fields = 'c_id', 'c_name', 'c_code', 'c_teacher', 'cnt_sign', 'student'

from .models import Course, Registration
from rest_framework import serializers
from course.models import Course
from users.serializer import UserSerializer


class CourseSerializer(serializers.ModelSerializer):
    c_teacher = UserSerializer()


    class Meta:
        model = Course
        fields = 'c_id', 'c_code', 'c_name', 'c_teacher', 'cnt_sign'


class RegistrationSerializer(serializers.ModelSerializer):
    user = UserSerializer()
    course = CourseSerializer()


    class Meta:
        model = Registration
        fields = 'user', 'course', 'cnt_abcense'


class RegistrationSerializerByCourse(serializers.ModelSerializer):
    user = UserSerializer()


    class Meta:
        model = Registration
        fields = 'user', 'cnt_abcense'


class RegistrationSerializerByUser(serializers.ModelSerializer):
    course = CourseSerializer()


    class Meta:
        model = Registration
        fields = 'course', 'cnt_abcense'


class RegistrationSerializer1(serializers.ModelSerializer):
    c_teacher = UserSerializer()
    student = serializers.SerializerMethodField()

    def get_student(self, obj):
        result_set = Registration.objects.filter(course=obj)
        return RegistrationSerializer(result_set, many=True).data


    class Meta:
        model = Course
        fields = 'c_id', 'c_name', 'c_code', 'c_teacher', 'cnt_sign', 'student'

from .models import Course,Registration
from rest_framework import serializers

from course.models import Course
from users.serializer import UserSerializer
class CourseSerializer(serializers.ModelSerializer):
    c_teacher = UserSerializer()
    class Meta:
        model = Course
        fields = (
            'c_id',
            'c_code',
            'c_name',
            'c_teacher',
            'cnt_sign'
        )

class RegistrationSerializer(serializers.ModelSerializer):
    user = UserSerializer()
    course = CourseSerializer()
    class Meta:
        model = Registration
        fields = (
            'user',
            'course',
            'cnt_abcense',
        )


class RegistrationSerializerByCourse(serializers.ModelSerializer):
    user = UserSerializer()
    # course = CourseSerializer()
    class Meta:
        model = Registration
        fields = (
            'user',
            # 'course',
            'cnt_abcense',
        )

class RegistrationSerializerByUser(serializers.ModelSerializer):
    #user = UserSerializer()
    course = CourseSerializer()
    class Meta:
        model = Registration
        fields = (
            #'user',
            'course',
            'cnt_abcense',
        )

class RegistrationSerializer1(serializers.ModelSerializer):
    c_teacher = UserSerializer()
    student= serializers.SerializerMethodField()

    def get_student(self, obj):
        result_set = Registration.objects.filter(course=obj) 
        return RegistrationSerializer(result_set, many=True).data

    class Meta:
        model = Course
        fields = (
            'c_id',
            'c_name',
            'c_code',
            'c_teacher',
            'cnt_sign',
            'student',
        )
    