嘿,有可能看到请求匹配的模型/序列化器。
例如,如果我的身体被发送:
project_id: 1,
title: "Hello",
message: "World"
运行类似的代码
matchingModel = AllMyModels.map(request.body)
并使matchingModel类似于Project
答案 0 :(得分:1)
# mode creation
class Test(models.Model):
name = models.CharField(max_length = 100)
class Meta:
db_table = 'test'
@classmethod
def create(cls, **kwargs):
clazz = cls(**kwargs)
return clazz
#create dictionary
dic = {}
dic['name'] = 'Test'
# create object
t = Test.create(**dic)