【发布时间】:2020-07-23 00:10:57
【问题描述】:
我的模特:
class Post_Data(models.Model):
id = models.AutoField(primary_key=True)
data = models.CharField(max_length=200)
我需要在模型中插入json数据,在邮递员中以“文件”的形式传递。
我试过了:
def post(self, request):
json_file = request.FILES['json_file']
with open(json_file) as f:
json_data = json.loads(f)
a = Post_data(data=json_data)
a.save()
但它不起作用。
【问题讨论】:
标签: python json django django-models django-views