SOITA/questions/serializers.py

28 lines
650 B
Python
Raw Normal View History

2021-12-05 13:50:34 +01:00
from rest_framework import serializers
from questions.models import Question
2021-12-12 11:35:35 +01:00
from answers.serializers import AnswerSerializer
2021-12-05 13:50:34 +01:00
class QuestionSerializer(serializers.ModelSerializer):
2021-12-12 11:35:35 +01:00
# answers = serializers.SerializerMethodField()
#
# def get_answers(self, instance: Question):
# return instance.get_answers_secret()
2021-12-05 13:50:34 +01:00
2021-12-12 11:35:35 +01:00
answers = AnswerSerializer(many=True, required=False)
2021-12-05 13:50:34 +01:00
class Meta:
model = Question
fields = (
"id",
"name",
"description",
"answers",
"test"
)
2021-12-12 11:35:35 +01:00
def create(self, validated_data):
import pdb;pdb.set_trace()