Afflatus
Afflatus

Reputation: 2452

How to get the first N elements in Django?

I have a django for-loop which is:

          {% for people in USPop %}

I would like to hand select the elements within the general dataset of USPop...e.g. like the first 3 elements or for just the 7-15 elements. How do I do that?

Note: I feel like the answer should be here, but I just couldn't find it...

https://docs.djangoproject.com/en/dev/ref/templates/builtins/#built-in-filter-reference

Upvotes: 2

Views: 389

Answers (1)

Wander Nauta
Wander Nauta

Reputation: 19625

What you're looking for is the slice filter on the page you linked.

Upvotes: 2

Related Questions