1
Django的Paginator與模型方法get_absolute_url
有什麼特別的規則嗎?我試圖調用這個方法,但它不工作?Django使用get_absolute_url方法進行分頁
這裏是我的模板:
<ul class="products thumb-info-list">
{% for product in products.object_list %}
<li class="col-md-3 product">
{% if product.on_sale %}
<a href="{{ product.get_ablsolute_url }}">
<span class="onsale">Sale!</span>
</a>
{% endif %}
<span class="thumb-info">
<a href="{{ product.get_ablsolute_url }}" class="add-to-cart-product">
<span><i class="icon icon-tag"></i>{{ product.title }}</span>
</a>
<a href="{{ product.get_ablsolute_url }}">
<span class="thumb-info-image">
<span class="thumb-info-act">
<span class="thumb-info-act-left"><em>View</em></span>
<span class="thumb-info-act-right"><em><i class="icon icon-plus"></i> Details</em></span>
</span>
<img alt="" class="img-responsive" src="{{ STATIC_URL }}{{ product.image_one }}">
</span>
</a>
<span class="thumb-info-content">
<a href="{{ product.get_ablsolute_url }}">
<h4>{{ product.title }}</h4>
<span class="price">
{% if product.on_sale %}
<del><span class="amount">${{ product.unit_price|floatformat:0 }}</span></del>
{% endif %}
<ins><span class="amount">${{ product.sale_price|floatformat:0 }}</span></ins>
</span>
</a>
</span>
</span>
</li>
{% endfor %}
</ul>
Wowzers!是的,我想這可能是這樣的。只需要一個新的眼睛就可以了。謝謝! –