Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6974133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:11:51+00:00 2026-05-27T17:11:51+00:00

I have a reusable HTML fragment that I use to list items. So to

  • 0

I have a reusable HTML fragment that I use to list items. So to list items in a view I just do:

variables = RequestContext(request, {
    'items': items,
}
return render_to_response('template_in_question',variables)

and the fragment is:

{% for item in items %}
    <p>Item: {{item.name}} </p>
{% endfor %}

So far so good. However, there are views where I want to use the same reusable fragment twice. For example, if I want to list the most sold items and the latest items, I need to create two copies of that reusable fragment:

The view would be like this:

variables = RequestContext(request, {
    'most_sold_items': most_sold_items,
    'latest_items': latest_items
}

and in the HTML would need to have two reusable HTML templates:

{% for item in most_sold_items %}
     <p>Item: {{item.name}}</p>
{% endfor %}

and a second one

 {% for item in latest_items %}
     <p>Item: {{item.name}}</p>
 {% endfor %}

So my question is: How can I use, in the same view, two or more item lists, and use a common HTML template for that? For example, in the view above pass “most_sold_items” and “latest_items” and somehow use just one HTML template to list each separately?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:11:52+00:00Added an answer on May 27, 2026 at 5:11 pm

    You can do it with the include tag. Basically, you’d end up with:

    <h1>Most sold items</h1>
    {% include "items.html" with items=most_sold_items only %}
    
    <h1>Latest items</h1>
    {% include "items.html" with items=latest_items only %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some reusable HTML snippets that I want to 'include' in a number
let us assume that I have a reusable business layer that further makes use
I have a fair number of Python scripts that contain reusable code that are
I have a reusable usercontrol that uses a few commands and corresponding keyboard gestures,
I have created a reusable class that fades in a loading message and indicator
I have written a function that retrieves a html template, then binds data using
Hi have a JQuery modal popup that I load HTML into. I have the
In my project I have a view (defined in a xib) that is a
I would like to have reusable ratings (typical layout with 5 stars). I have
I have been tasked with creating a reusable process for our Finance Dept to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.