SOITA/trials/serializers.py
Hubert Jankowski d9ad2c2f9d test visibility
2022-04-09 13:02:21 +02:00

30 lines
694 B
Python

from rest_framework import serializers
from questions.serializers import QuestionSerializer
from trials.models import Test
from categories.serializers import CategorySerializer
class TestSerializer(serializers.ModelSerializer):
questions = QuestionSerializer(many=True, required=False)
#category = CategorySerializer(required=False)
class Meta:
model = Test
fields = (
"id",
"name",
"passing_score",
"questions",
"visible",
"category",
)
def create(self, validated_data):
instance = Test.objects.create(
**validated_data
)
return instance