Example:
@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))
Is PyCharm able to do HTML Syntax checking and highlighting in Python strings like above?
from PyCharm: HTML Syntax checking and highlighting in Python strings
No comments:
Post a Comment