-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Aidas,
thx for the fast help. I hope i get better with django soon, that I can help others too. greets Sven Aidas Bendoraitis wrote: > Hi Sven! > > To get a value from a dictionary by a variable key, you either need a > custom filter like {{ dictionary|dict_value:key }} > > def dict_value(dict, key): > """ returns the value of a dictionary key ... > """ > try: > return dict[key] > except: > return None > > register.filter('dict_value', dict_value) > > ... or you can go through the items like this: > > {% for key_value in dictionary.items %} > <h1>{{ key_value.0 }}{# the key #}</h1> > {% for item in key_value.1 %}{# the value, that is the queryset #} > {{ item }} > {% endfor %} > {% endfor %} > > Regards, > Aidas Bendoraitis aka Archatas > > > > On 5/17/07, Sven Herzing <[EMAIL PROTECTED]> wrote: > Hi, > > I'm sorry that I have to ask again for help, but, I couldn't figure it > out how to access nested directories in templates. > > My Problem ist, that I have 3 categories (which I get from the DB), and > for every category a queryset. > > and the structure looks like this > > {'rahmen': > [<Product: rahmen1, ra1>, <Product: rahmen3, ra3>], > 'laufrad': > [<Product: foobar, #0000X>, <Product: laufrad1, lr1>, <Product: > laufrad2, lr2>], > 'lenker': > [<Product: foobar, #0000X>, <Product: lenker1, len1>, <Product: > lenker2, len2>, <Product: lenker3, len3>] > } > > I have the keywords for the dictionary in an array (mygroups) which I > access in the template like this: > > {% for entry in mygroups %} > {{ entry }}<p> > > and here I would like to access the dictionaries like this > > {% for prod in product.entry %} > {{ prod.name }} > {% endfor %} > {% endfor %} > > The template manual says that if there is a point in a variable, it trys > to treat it like a dictionary or a list, but what if the word after the > point isn't parameter of the dictironary? > I also tried sth like this {% for prod in product.{{ entry }} %}, but > this didn't work either. > > Is this kind of access possible? > > regards > Sven Herzing > > >> > -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGTsze4uR1pQ+2BeoRAtGvAKCV41i3tXin9/jb81Meirsqqpi33gCcDHWO oIhx7sa3qdPsn8+bnPkRvn4= =NwHW -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---