From 0cdaef9348dbdab7415dbcc938df1d12e3e67aea Mon Sep 17 00:00:00 2001 From: guohongze Date: Thu, 18 Apr 2019 09:42:36 +0800 Subject: [PATCH] fix resource export bug --- branches/resource.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/branches/resource.py b/branches/resource.py index ef692534..0565b9f9 100644 --- a/branches/resource.py +++ b/branches/resource.py @@ -123,9 +123,12 @@ def resource_export(request): if r.branch: br = Branch.objects.get(name=r.branch) else: - br = "" - writer.writerow([str2gb(br.region.name), str2gb(r.branch.name), r.sn, str2gb(r.name), str2gb(r.spec), - str2gb(r.budget), str2gb(r.paid), str2gb(r.contract), str2gb(r.contract_start), str2gb(r.contract_end), - str2gb(r.supplier), str2gb(r.service_phone), str2gb(r.owner), str2gb(r.owner.phone), + br = None + + writer.writerow([str2gb(br.region.name if br else br), str2gb(r.branch.name if r.branch else None), r.sn, + str2gb(r.name), str2gb(r.spec),str2gb(r.budget), str2gb(r.paid), str2gb(r.contract), + str2gb(r.contract_start), str2gb(r.contract_end), + str2gb(r.supplier), str2gb(r.service_phone), str2gb(r.owner if r.owner else None), + str2gb(r.owner.phone if r.owner else None), str2gb(r.description)]) return response