30 lines
694 B
Python
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
|
|
|