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 548613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:05:52+00:00 2026-05-13T11:05:52+00:00

My view code looks basically like this: context = Context() context[‘some_values’] = [‘a’, ‘b’,

  • 0

My view code looks basically like this:

context = Context() 
context['some_values'] = ['a', 'b', 'c', 'd', 'e', 'f']
context['other_values'] = [4, 8, 15, 16, 23, 42]

I would like my template code to look like this:

{% for some in some_values %} 
  {% with index as forloop.counter0 %} 
    {{ some }} : {{ other_values.index }} <br/> 
  {% endwith %} 
{% endfor %} 

And I would expect this to output:

a : 4 <br/> 
b : 8 <br/> 
c : 15 <br/> 
d : 16 <br/> 
e : 23 <br/> 
f : 42 <br/> 

Is this possible? I’m finding that my “with” statement is actually working, but then using that variable as a reference isn’t working. I suspect that for {{ other_values.index }} it’s doing other_values[‘index’] instead of other_values[index]. Is this possible?

  • 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-13T11:05:52+00:00Added an answer on May 13, 2026 at 11:05 am

    zip(some_values, other_values), then use it in template

    from itertools import izip
    some_values = ['a', 'b', 'c', 'd', 'e', 'f']
    other_values = [4, 8, 15, 16, 23, 42]
    context['zipped_values'] = izip(some_values, other_values)
    
    {% for some, other in zipped_values %}
        {{ some }}: {{ other }}  <br/>
    {% endfor %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My view code looks basically like this: context = Context() context['my_dict'] = {'a': 4,
Often in my code I start threads which basically look like this: void WatchForSomething()
In the aspx code view , we can code like this: <asp:ListBox runat=server> <asp:ListItem
so basically my application looks like this <!DOCTYPE html> <html> <head> ... </head> <body>
Consider this simplified view of some code with which I'm working: @Stateless(...) @Remote(...) @TransactionAttribute(TransactionAttributeType.MANDATORY)
I want DRY/reuse as much editor code (View and Model) as possible. Some of
How can I change the position of view through code? Like changing its X,
I was just wondering if this approach looks like a good practice for apps
In the MVC View code below, isLoggedInDb is underlined in green with a tooltip
EDIT: I've altered the code to now read: View code: <h3>Your Orders:</h3> <table class=order-items>

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.