Monday, October 31, 2011

Re: variables in a dict in a template

On Mon, Oct 31, 2011 at 2:36 AM, kenneth gonsalves
<lawgon@thenilgiris.com> wrote:
> On Sun, 2011-10-30 at 12:00 -0400, Kurtis Mullins wrote:
>> One way to go about it is to create multiple, nested objects. For
>> example:
>>
>> Score - Rounds ---- Holes
>>
>> Then in your template, you'd do something along the lines of:
>>
>> {% for round in game.rounds %} {% for hole in round.holes %}
>> {{ hole.score }} {% endfor %} {% endfor%}
>>
>>
>> Hopefully that helps a little :)
>
> that was my original structure - but there was too much code required,
> and after several years of using it, I still found difficulty in
> understanding and upgrading it. The present structure is simple and
> flexible - the only downside is that I have write some extra html.
> Anyway it is just one template and I suppose I have to live with it.
> --
> regards
> Kenneth Gonsalves

When the going gets complicated, my simple mind reaches for python.
Maybe a custom template filter?

Bill

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment