使用方法:
Model类.objects.create(**字典格式数据)
示例
比如一个model:
class MyModel(models.Model):
data1 = models.CharField(max_length=255)
data2 = models.CharField(max_length=255)
data3 = models.CharField(max_length=255)
data4 = models.CharField(max_length=255)
data5 = models.CharField(max_length=255)
添加方法:
my_data = {
"data1": "a",
"data2": "b",
"data3": "c",
"data4": "d",
"data5": "e",
}
MyModel.objects.create(**my_data)