Django quiz application code example

Example: how to make django quiz app advance

class QuizSerializer(serializers.ModelSerializer):  def getFullname(self, obj): ...  def getQCount(self, obj):    return obj.question_count #we defined this method in models.py  questions=serializers.HyperlinkedRelatedField(...)  author_fullname=serializers.SerializerMethodField("getFullname")  question_count=serializers.SerializerMethodField("getQCount")  class Meta:    fields = [      'id',      'title',      'author',      'author_fullname',      'question_count',      'created_at',      'questions'    ]    model = models.Quiz

Tags:

Php Example