Files
Tablequizwiki/content/serializers.py

30 lines
890 B
Python
Raw Normal View History

import logging
from rest_framework import serializers
from content.models import Question, Label, Level
class QuestionSerializer(serializers.Serializer):
# question = serializers.CharField()
# awnser = serializers.CharField()
# buzzword = serializers.CharField(required=False)
# level = serializers.IntegerField()
# labels = serializers.MultipleChoiceField(choices=[(l.id, l.name) for l in Label.objects.all()], required=False)
class Meta:
model = Question
# fields = ['id', 'name', 'description', 'level', 'labels', 'medias', ]
fields = '__all__'
"""
def create(self, validated_data):
return Question.objects.create(**validated_data)
def update(self, instance, validated_data):
instance.name = validated_data.get('name', instance.name)
# ...
instance.save()
return instance
"""