好吧,我正在尝试通过使用 Django-excel 上传 excel 文件来更新数据库,但是数据没有保存到 db,我也没有收到任何错误消息!!!
我的观点.py
@login_required
def customerbulk(request):
action = 1
if request.method == "POST":
form = productupload(request.POST, request.FILES)
def choice_func(row):
q = request.user
row[0] = q
return row
if form.is_valid():
request.FILES['select_excel_file'].save_book_to_database(
models=[customer],
initializers=[choice_func],
mapdicts=[
['user','name','address','state_code','shipping_address','shipping_state_code','email','telephone','GSTIN','PAN','discount','notes']]
)
return HttpResponseRedirect(reverse('customerbulk'),messages.add_message(request, messages.SUCCESS,'Customers added Succesfully'))
else:
form = productupload()
return render(request,'productbulk.html',{'form': form,'action':action,})