1

我使用 Zeep 将数据字典发送到外部 SOAP API。

我这样做了,它正在工作:

my_date = (form.cleaned_data['my_date'])
#This comes from a Django form

data2 = {
"CashBookEntryData": {
"Type" : "FinanceVoucher",
"CashBookHandle" : { "Number" : 1 },
"AccountHandle" : { "Number" : 5820 },

"Date" : my_date,

"VoucherNumber" : 100,
"Text" : "Dagenssalg",
"AmountDefaultCurrency" : 0,
"CurrencyHandle" : { "Code" : "DKK" },
"Amount" : beloeb_salg,
"DepartmentHandle" : { "Number" : 1 }
}
}

为了能够更好地控制 dict 的构造方式,我将其更改为:

data1 =collections.OrderedDict()
data1["CashBookEntryData"] = {}
data1["CashBookEntryData"]["Type"] = "FinanceVoucher"
data1["CashBookEntryData"]["CashBookHandle"] = { "Number" : 1 }
data1["CashBookEntryData"]["AccountHandle"] = { "Number" : 5820 },

data1["CashBookEntryData"]["Date"] = my_date,

data1["CashBookEntryData"]["VoucherNumber"] = 100,
data1["CashBookEntryData"]["Text"] = "Dagenssalg",
data1["CashBookEntryData"]["AmountDefaultCurrency"] = 0,
data1["CashBookEntryData"]["CurrencyHandle"] = { "Code" : "DKK" },
data1["CashBookEntryData"]["Amount"] = 9999,
data1["CashBookEntryData"]["DepartmentHandle"] = { "Number" : 1 }

但现在我得到一个类型错误:combine() 参数 1 必须是 datetime.date,而不是元组

非常感谢任何帮助!最好的问候克雷斯滕布赫

编辑:

试:

dato = form.cleaned_data['dato']
dato = datetime.datetime.strptime(dato, "%Y-%m-%d")

给出同样的错误

4

0 回答 0