我的程序当前需要打印设置模型中每个数据库条目的报告
它读取模型的pk并使用该pk检查设置条目的项目
然而,当我点击应该打印报告的按钮时,我得到了一个trialBalanceMonthly() got multiple values for argument 'TBMreports_pk'
错误
这是我的密码:
reportsHome.html:
{% for x in model %}
<a href="#" class='list-group-item active'>{{ x.Complex }} Reports</a>
<div>
<hr>
<a href="{% url 'trialBalanceMonthly' TBMreports_pk=x.pk %}" type="button" class="btn btn-outline-primary btn-sm" >{{ x.Complex }} Trial Balance Monthly</a>
<a href="{% url 'trialBalanceYearly' TBYreports_pk=x.pk %}" type="button" class="btn btn-outline-primary btn-sm" >{{ x.Complex }} Trial Balance YTD</a>
<br>
<a href="{% url 'incomeStatementMonthly' ISMreports_pk=x.pk %}" type="button" class="btn btn-outline-primary btn-sm" >{{ x.Complex }} Income Statement Monthly</a>
<a href="{% url 'incomeStatementYearly' ISYreports_pk=x.pk %}" type="button" class="btn btn-outline-primary btn-sm" >{{ x.Complex }} Income Statement YTD</a>
<hr>
</div>
<br>
{% endfor %}
Views.py(我已经删除了一些生成变量的代码,以使这成为一个更具重现性的问题)
--这是每个报表视图函数的外观
def trialBalanceMonthly(TBMreports_pk):
pkForm = get_object_or_404(SettingsClass, pk=TBMreports_pk)
complexName = pkForm.Complex
### Printing Trial Balance PDF
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'attachment; filename=TrialBalanceMonthly' + \
str(datetime.now()) + '.pdf'
response['Content-Transfer-Encoding'] = 'binary'
content = {'printDescM': printDescM, 'printAccM': printAccM, "xtrbMonth": xtrbMonth,
'xCreditTotalM': xCreditTotalM, 'xDebitTotalM': xDebitTotalM, 'complexName': complexName,
'printZeroM': printZeroM}
html_string = render_to_string('main/reports/trialBalanceMonthly.html', content)
html = HTML(string=html_string)
result = html.write_pdf()
with tempfile.NamedTemporaryFile(delete=True) as output:
output.write(result)
output.flush()
output.seek(0)
response.write(output.read())
else:
redirect('main/reportsHome')
url.py:
#Print Each Report
path('accConnect/trialBalanceMonthly/<int:TBMreports_pk>' , views.trialBalanceMonthly, name='trialBalanceMonthly'),
path('accConnect/trialBalanceYearly/<int:TBYreports_pk>' , views.trialBalanceYearly, name='trialBalanceYearly'),
path('accConnect/incomeStatementMonthly/<int:ISMreports_pk>', views.incomeStatementMonthly, name='incomeStatementMonthly'),
path('accConnect/incomeStatementYearly/<int:ISYreports_pk>', views.incomeStatementYearly, name='incomeStatementYearly'),
]
我得到的确切错误信息如下所示(当我点击试算表每月按钮时)
TypeError at /accConnect/trialBalanceMonthly/2
trialBalanceMonthly() got multiple values for argument 'TBMreports_pk'
目前没有回答
相关问题 更多 >
编程相关推荐