Django Rest Framework ManyToManyField ModelSerializer数据格式

时间:2015-05-25 19:57:04

标签: django-rest-framework django-orm

附录数据如何看起来有效?我从php网站发送数据,并尝试了几种由DJF解析为以下格式的内容。两者都无效。

'information.appendices.file.0'
'information.appendices.file[0]'

class Information(models.Model):
    type = models.CharField(max_length=10)
    text = models.TextField(blank=True, null=True)
    url = models.URLField(blank=True, null=True)
    appendices = models.ManyToManyField('Appendix')


class Appendix(models.Model):
    file = models.FileField(upload_to='information/appendices')


class AddInformationSerializer(ModelSerializer):
    appendices = AppendixSerializer(many=True, required=False)

0 个答案:

没有答案