【问题标题】:Django Pagination with get_absolute_url method使用 get_absolute_url 方法进行 Django 分页
【发布时间】:2014-02-26 09:01:40
【问题描述】:

他们在使用带有模型方法get_absolute_url 的Django 分页器时有什么特殊规则吗?我正在尝试调用此方法,但它不起作用??

这是我的模板:

<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>

【问题讨论】:

    标签: python django pagination


    【解决方案1】:

    您的模板中似乎有一个错字:

    product.get_ablsolute_url
    

    应该是:

    product.get_absolute_url
    

    【讨论】:

    • 哇!是的,我认为它可能是这样的。只需要重新审视它。谢谢!
    猜你喜欢
    • 2017-08-28
    • 2012-04-28
    • 2010-12-28
    • 1970-01-01
    • 1970-01-01
    • 2016-10-12
    • 1970-01-01
    • 2014-08-28
    • 2014-04-26
    相关资源
    最近更新 更多