Marshmallow Nested Serializer KeyError:u' Manager'

时间:2017-02-27 04:08:53

标签: python django django-rest-framework marshmallow

我使用Marshmallow的嵌套序列化程序并收到错误" KeyError:u' manager'"。

以下是我的序列化程序:

class ShiftSerializer(Schema):

    agent = fields.String()
    date = fields.String()
    end = fields.String()
    status = fields.String()

class KPIShiftSerializer(Schema):

    interval = fields.DateTime()
    incoming = fields.Integer()
    duration = fields.Decimal()
    shifts_future = fields.Nested(ShiftSerializer, many=True)
    shifts_current = fields.Nested(ShiftSerializer, many=True)
    shifts_ending = fields.Nested(ShiftSerializer, many=True)

我的模特:

class Shift(models.Model):

    agent = models.CharField(default=" ", max_length=200)
    date = models.CharField(default='01/01/1900', max_length=10)
    end = models.DateTimeField(default=utc.localize(datetime(1900,1,1)))
    status = models.CharField(default='Available', max_length=200)

class KPI(models.Model):

    interval = models.DateTimeField(default=timezone.now)
    incoming = models.IntegerField(default=0)
    duration = models.FloatField(default=0)
    shifts_future = models.ManyToManyField(Shift, related_name="returning")
    shifts_current = models.ManyToManyField(Shift, related_name="staffed")
    shifts_ending = models.ManyToManyField(Shift, related_name="leaving")

0 个答案:

没有答案