現在我正在結算應用程序。我有一個自定義設計的結算頁面。該頁面可以包含15個產品。如果我打印超過15種產品,則會覆蓋其頁腳。所以,如果超過15個產品,則每15個項目創建一個新頁面。我怎樣才能做到這一點。Django循環模板,每個15個項目的新頁面
我查看
@login_required
def print_sale(request,uuid):
current_sale = Sales.objects.filter(uuid=uuid,deleted=0,shop_id = get_current_shop_id(request)).annotate(total=Sum('sale_products__subtotal'),total_received=Sum('sale_payment__amount'))
return render_to_response('sales/print.html',{'current_sale':current_sale},context_instance=RequestContext(request))
我的模板
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>print</title>
{% load static %}
<link rel="stylesheet" href="{% static 'css/print.css' %}" />
<script type="text/javascript" src="{% static 'js/print.js' %}"></script>
</head>
<body>
<section class="wrapper">
{%if current_sale %}
{% for sale in current_sale %}
<section id="top">
<section id="bill_details" class="style1">
<h2>Bill To :</h2>
<p>
{{ sale.customer.name }} , {{ sale.customer.email }} , {{sale.customer.mobile}}
</p>
<p class="address">
{{ sale.customer.address }}
</p>
</section>
<div class="right">
<p>
<b>Date <small>:</small></b>{{ sale.sale_date }}
</p>
<p>
<b>Invoice No<small>:</small></b> #{{ sale.id }}
</p>
</div>
<br class="clear" />
</section>
<table>
<tr>
<th>Code</th>
<th>Name</th>
</tr>
{% for product in sale.sale_products_set.all %}
<tr class="parent">
<td>{{ product.product.code }}</td>
<td>{{ product.product.name }}</td>
</tr>
{% endfor %}
</table>
{% endfor %}
{% endif %}
</section>
</body>
</html>