How to add Django model method to serializer without explicit defining the fields?

前端 未结 0 1951
醉酒成梦
醉酒成梦 2021-01-31 06:31

model

class Doctor(models.Model):
   ...tons of fields
   def no_of_ratings(self):
     ratings = Rating.objects.filter(doctor=self)
     return len(ratings)


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题