KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm running a query to get the 5 latest News items. In my template, I want to display the first item in one location, then the remaining 4 further down the page. In my template, I do something like this: {% for n in news|slice:":1" %} {{ n.headline }} {% endfor %} ... more HTML ... {% for n in news|slice:"1:" %} {{ n.headline }} {% endfor %} When I look in the Debug Toolbar, this results in two queries to the database: one with LIMIT 1 and another with LIMIT 4 OFFSET 1 , but otherwise the same. I appreciate this is Django's way of intelligently only requesting the stuff you actually use, but in this case it seems a little excessive. What's the best way to do this kind of thing?
Tags (comma-separated)
Save Edits
Cancel