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

  • Home
  • SEARCH
  • 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 8289227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:27:32+00:00 2026-06-08T12:27:32+00:00

I have a dict: >>> some_dict {1: [‘String1’, ‘String2’, ‘String3′,’String4’ ], 2: [‘String1_2’, ‘String2_2’,

  • 0

I have a dict:

 >>> some_dict
{1: ['String1', 'String2', 'String3','String4' ],
 2: ['String1_2', 'String2_2', 'String3_2', 'String4_2' ],}

In my template i want to iterate over this dict and display values in html. So i sent this dict from view:

return render_to_response('tournament.html', 
        {.....
        'some_dict' : some_dict,
        'some_dict_range' : range(4),
             .....
        })

In tournament.html i trying to iterate over some_dict. I want to get output that should looks like:

'String1', 'String2', 'String3','String4'

 {% for iter1 in some_dict_range%}         
{{some_dict.0.iter1}}<br>{% endfor %}

And as result, i get nothing.
But when i trying to get same result without iterator:
some_dict.0.0, some_dict.0.1, etc. i get what i need (‘String1’, ‘String2’, ‘String3′,’String4’).
And when i trying to view values of “iter1” i get the right digits:

 {% for iter1 in some_dict_range%}         
{{iter1}}<br>  {% endfor %}

0, 1, 2 …
Why this doesn’t work this way? And if i wrong in design of this, how it should looks like? I mean – what the right way to iterate over this dict and display values in html-template?

  • 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-06-08T12:27:35+00:00Added an answer on June 8, 2026 at 12:27 pm

    Shouldn’t:

    {{some_dict.0.iter1}}<br>{% endfor %}
    

    Be:

    {{some_dict.iter1.0}}<br>{% endfor %}
                ^^^^^^^
    

    Else you’re trying to access some_dict[0] which isn’t present…

    To avoid passing in the range (as I assume you’re wanting to output the dict in key order), you can use the following:

    {% for k, v in some_dict.items|sort %}
        Position {{ k }} has a first value of {{ v.0 }} and has:<br>
        {{ v|join:"<br/>" }}
        {% for item in v %}
            {{ item }}
        {% endfor %}
    {% endfor %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dict passed to my template, some of the element names /
I have a dict which contains some lists and some dicts, as illustrated below.
Let's say that I have class , that uses some functionality of dict .
Have dict like: mydict= {'a':[],'b':[],'c':[],'d':[]} list like: log = [['a',917],['b', 312],['c',303],['d',212],['a',215],['b',212].['c',213],['d',202]] How do i
My issue is as follows. We have dict that has all keys and values
I have a dict object. I dumped the data using this: for alldata in
I have a default dict of dicts whose primary key is a timestamp in
I have a list of dict convert from yaml, but how do I merge
I have 0 or more dict s in a list: >>> dicts = [dict(a=3,
I have a 2D dictionary as follows dict = {'182.12.17.50': {'185.23.15.69': 30, '175.12.13.14': 14},

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.