assets = Asset.objects.filter(no=row[4]) if not assets: asset = Asset() asset.no = row[4] asset.sub_no = row[5] dt = datetime.datetime.strptime(row[10], '%d/%m/%Y').date() asset.capitalized = dt types = AssetType.objects.filter(name=row[3]) print types if types: asset.asset_type = types.first() else: s = AssetType(name=row[3]) s.save() asset.asset_type = s asset.descr = row[11] asset.add_descr = row[12] asset.serial = row[14] asset.office_id = 6 if "huuk" in row[17]: asset.office_id = 2 elif "pei" in row[17]: asset.office_id = 1 elif "osra" in row[17]: asset.office_id = 5 elif "j" in row[17]: asset.office_id = 4 elif "ap" in row[17]: asset.office_id = 3 p = Program.objects.filter(name=row[21]) if p: