Tag: foreign key relationship

Python XLWT外键值

我正在导出数据库字段为Excel文件,一切正常,但我的外键字段被打印为外键ID而不是实际值。 我该如何解决? 这里是我的代码: book = xlwt.Workbook(encoding='utf8') sheet = book.add_sheet('Expense summary', cell_overwrite_ok=True) header_style = xlwt.easyxf('font:height 280, color blue, bold 1; border: bottom thick;') sum_style = xlwt.easyxf('font:height 200, color green, bold 1; border: top thick;') date_style = xlwt.XFStyle() date_style.num_format_str = 'DD-MM-YYYY' currency_style = xlwt.XFStyle() currency_style.num_format_str = '#,##0.00' xls_values = expense.filter( user=request.user.id).values_list('date', 'amount', 'towho', 'forwhat', 'category', 'payment_method') headers […]