Opened 17 years ago

Closed 17 years ago

#5699 closed (invalid)

Generic views' page_range values incomparable to (current) page integer

Reported by: Simon Litchfield <simon@…> Owned by: nobody
Component: Generic views Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Consider this typical example --

<div class="pagenav">

Page
{% for p in page_range %}
<a href="{{ url }}{{ p }}/"{% ifequal page p %} class="sel"{% endifequal %}>{{ p }}</a>
{% endfor %}
{% if next_page %}
<a href="{{ url }}{{ next_page }}/">Next</a>
{% endif %}

</div>

Ooops, doesn't work! Ifequal doesn't seem to be able to compare the current page (integer) to variables in the page_range list.

Aside, it seems type handling can be unnecessarily tedious at times, particularly when using things like Decimal.

Change History (2)

comment:1 by Simon Litchfield, 17 years ago

Let me try that again --

<div class="pagenav">
    Page
    {% for p in page_range %}
    <a href="{{ url }}{{ p }}/"{% ifequal page p %} class="sel"{% endifequal %}>{{ p }}</a>
    {% endfor %}
    {% if next_page %}
    <a href="{{ url }}{{ next_page }}/">Next</a>
    {% endif %}
</div>

comment:2 by Malcolm Tredinnick, 17 years ago

Resolution: invalid
Status: newclosed

Seems to work fine here. Using this test case and the template fragment you posted

data = {
    'queryset': Session.objects.all(),
    'template_name': 'foo.html',
    'paginate_by': 2,
}

urlpatterns = patterns('',
        (r'^example/(?P<page>\d+)/$', object_list, data),
)

with more than two items in my sessions table, I get the "page" item having the "sel" class added (and only that item).

Please reopen if you have a short, complete example that demonstrates the problem.

Note: See TracTickets for help on using tickets.
Back to Top