【发布时间】:2021-04-07 13:35:05
【问题描述】:
例子:
@register.simple_tag
def last_orders(user):
rows = []
for order in Order.objects.filter(user=user).order_by('-offer__date'):
rows.append(format_html('<tr><td>{}</td><td>{}</td><td>{} Eur</td><td class="int col-1">{}</td><td>{} Eur</td></div>',
order.offer.date, order.offer.text, order.offer.price, order.amount, order.amount*order.offer.price))
if not rows:
return format_html('<div>No orders up to now.</div>')
return format_html('''Last Orders:
<table class="table table-striped">
<tr><th>Date</th><th>Text</th><th>Price</th><th class="col-1">Amount</th><th>Sum</th></tr>
{}
</table>
''', join(rows))
PyCharm 是否能够像上面那样在 Python 字符串中进行 HTML 语法检查和高亮显示?
【问题讨论】:
标签: python html pycharm syntax-highlighting