我正在使用import_export库将数据从CSV上载到数据库,出于数据库目的,我正在使用MongoDB
from django.shortcuts import render
from tablib import Dataset
from .resources import whsStgResource,whsMstResource ,whsInventoryResource ,stgMstResource ,stgInventoryResource ,prodMstResource
from .models import whs_mst,whs_stg,stg_inventory,whs_inventory,stg_mst,prod_mst
from django.http import HttpRequest,HttpResponse
import io, json
import csv
def index(request):
return render(request, "import.html")
def prod_mst(request):
if request.method == 'POST':
prodmst_resource = prodMstResource()
dataset = Dataset()
new_persons = request.FILES['myfile']
new_persons2 = new_persons.read().decode('UTF-8')enter code here
imported_data = dataset.load(new_persons2)
result = prodmst_resource.import_data(dataset, dry_run=True)
if not result.has_errors():
prodmst_resource.import_data(dataset, dry_run=False)
return render(request, 'index.html')
错误:
在/ prodmst /
中配置不正确未提供异常消息