I've got the following in my template:
{% if reference_set.count %}
<ul>
{% for reference in reference_set.all|slice:":5" %}
<li><a href="{{ reference.website }}">{{ reference.name }}</a></li>
{% endfor %}
</ul>
{% endif %}
If there are more then 5 references I'ld like to show a 'more' link that
leads to a list of all references.
Something like (pseudocode):
{% if reference_set.count > 5 %}
<a href="/path/to/references">more</a>
{% endif %}
Anybody know how to do that?
Or am I missing something obvious?
If there are more then 5 references I'ld like to show a 'more' link thatleads to a list of all references.Something like (pseudocode):{% if reference_set.count > 5 %}<a href="/path/to/references">more</a>{% endif %}Anybody know how to do that?Or am I missing something obvious?
Not exactly this. Here a DB (Postgres at least) will complain that it
can't set OFFSET without LIMIT. This would work:
{% if reference_set.all|slice:"5:6" %}
Using sqlite, django also complained with AssertionError 'offset'
is not allowed without 'limit'.
Ivan's variation does the trick.
Thanks to both of you :)
cheers
Steven