如何继续使用下载的文件?将其解析为模型views.pydef model_form_upload(request):if request.method == 'POST': form = DocumentForm(request.POST, request.FILES) if form.is_valid(): form.save() return redirect('home')else: form = DocumentForm()return render(request, 'core/model_form_upload.html', { 'form': form})my model.pyclass Document(models.Model):description = models.CharField(max_length=255, blank=True)document = models.FileField(upload_to='documents/')uploaded_at = models.DateTimeField(auto_now_add=True)class Parameters(models.Model):par_time = models.DateTimeField('date')par_recipe = models.CharField(max_length=200)par_machine = models.CharField(max_length=200)par_fa = models.CharField(max_length=200)par_ag_typ = models.CharField(max_length=200)par_rollennr = models.IntegerField(default=0)par_definition_id = models.IntegerField(default=0)par_name = models.CharField(max_length=200)par_value = models.IntegerField(default=0)用于下载 Excel 文件 (xlsx)。xlsx 中的字段按照模型中的描述表示。一旦我没有尝试,我是 Django 的新手,我一无所有
添加回答
举报
0/150
提交
取消