Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Whats the point of having dicts in templates if one cannot access them by key?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Lachlan Musicman  
View profile  
 More options Nov 14 2012, 1:32 am
From: Lachlan Musicman <data...@gmail.com>
Date: Wed, 14 Nov 2012 18:31:14 +1200
Local: Wed, Nov 14 2012 1:31 am
Subject: Re: Whats the point of having dicts in templates if one cannot access them by key?
I used the SortedDict  datastructure :)

https://docs.djangoproject.com/en/dev/ref/utils
or
/path/django-docs/ref/utils.html#django.utils.datastructures.SortedDict

On Wed, Nov 14, 2012 at 4:40 PM, Juan Pablo Tamayo <jtama...@gmail.com> wrote:

> Let me explain, I have a nested dictionary like:

> agenda = {'3': {'2012-11-11': <MyObject>, '2012-11-14': <MyObject>, ...},
>   '7': {'2012-11-9': <MyObject>, },
>   '2': {'2012-10-28': <MyObject>},
>   }

> And I want to access it by specifying the two keys. I've red that i must
> access the dict like (where attribute is an attribute of <MyObject>:

> {% for k, a_dict in agenda.items %}
>   {{ k }}
>   {% for k2, v in a_dict.items %}
>     {{ k }}-{{ k2 }}-{{ v.attribute }}
>   {% endfor %}
> {% endfor %}

> But, whats the point of using dicts if I have to access the values in
> whatever order the <Dict>.items() gives me the keys and values?

> What if I need to access these values in a specified order? (for the outer
> dict AND the inner ones)

> Is there a way to access a two-dimensional container IN AN PRE-SPECIFIED
> ORDER?

> Thaks for any advise.

> pablete

> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/y5GJm9E1D4YJ.
> 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.

--
...we look at the present day through a rear-view mirror. This is
something Marshall McLuhan said back in the Sixties, when the world
was in the grip of authentic-seeming future narratives. He said, “We
look at the present through a rear-view mirror. We march backwards
into the future.”

http://www.warrenellis.com/?p=14314


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.