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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:42:37+00:00 2026-05-13T01:42:37+00:00

I hate to ask here but I am stumped and so were the guys

  • 0

I hate to ask here but I am stumped and so were the guys in irc.

The template does not display the contents of the list I am trying to display.

{{ bet }} alone also displays no values. What am I missing?

Template:

{% for bet in bets %}
<tr>
    <td><div>{{ bet.game_num }}</div></td>
    <td><div>{{ bet.home_team }}</div></td>
    <td><div>{{ bet.home_odds }}</div></td>
    <td><div id="home-odds-checkbox"><input type="checkbox"></div></td>
    <td><div>{{ bet.visiting_team }}</div></td>
    <td><div>{{ bet.visiting_odds }}</div></td>
    <td><div id="visiting-odds-checkbox"><input type="checkbox"></div></td>
    <td><div>{{ bet.tie_odds }}</div></td>
    <td><div id="tie-odds-checkbox"><input type="checkbox"></div></td>
</tr>
{% endfor %}

View:

def choose_bets(request):
    # Should be a post to get to this page
    num_games = int(request.POST['games']) + 1

    # Fill BetData with teams and odds
    bets = []
    for x in range(1, num_games):
        try:
            league_id = int(request.POST[str(x) + '-league'])
            game_num = int(request.POST[str(x) + '-game_num'])
            home_team = request.POST[str(x) + '-home_team']
            visiting_team = request.POST[str(x) + '-visiting_team']
            home_odds = float(request.POST[str(x) + '-home_odds'])
            visiting_odds = float(request.POST[str(x) + '-visiting_odds'])
            tie_odds = float(request.POST[str(x) + '-tie_odds'])
            skip_game = False

        except ValueError:
            league_id,game_num,home_odds,visiting_odds,tie_odds = 0,0,0,0,0 # bad fix
            home_team,visiting_team = '',''
            skip_game = True    # Do not include entry in calculation

        finally:
            bets.append([game_num, league_id, home_team, visiting_team, home_odds, visiting_odds, tie_odds, skip_game])

    return render_to_response('choose_bets.html', locals(), context_instance=RequestContext(request))

Context of bet variable:

‘bets’: [[1, 5, u”, u”, 1.0, 1.0, 3.0], [2, 4, u”, u”, 2.0, 2.0, 43555.0], [3, 3, u”, u”, 3.0, 3.0, 5.0]]

  • 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-13T01:42:37+00:00Added an answer on May 13, 2026 at 1:42 am

    The template is referring to named fields in bet, but you passed in an array.

    Either change your append in choose_bets like this:

    bets.append(dict(game_num=game_num, league_id=league_id, home_team=home_team, visiting_team=visiting_team, home_odds=home_odds, visiting_odds=visiting_odds, tie_odds=tie_odds, skip_game=skip_game))
    

    So you now have a dict with keys you can reference as-is from your template.

    Or… change the template to use the array you are passing in. For example instead of:

    <td><div>{{ bet.game_num }}</div></td>
    

    Use:

    <td><div>{{ bet.0 }}</div></td>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I hate to ask but I've searched all over the internet trying to figure
Okay I hate to ask this question ... but here goes. I am writing
I hate that I have to ask a homework question on here, but I
I hate to have to ask, but I'm pretty stuck here. I need to
I hate to ask this here, but many people on stackoverflow have talked about
I'd hate to ask an intentionally subjective question on here, but I don't have
I know you guys hate helping with homework, but I thought I might ask
I hate to ask such a general question, and this is not a write
I hate to be the third person to ask this, but the previous two
I hate to ask this question on this forum, but I'm having a lot

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.