Re: Seeing if a variable value is within a dictionary key value within a list of dictionaries

2012-09-08 Thread Tim Chase
On 09/08/12 14:45, Jason wrote: > thank you for your responses. I think, following your advice, I'll have to > abandon my attempts to handle this in the template, and sort this out in > the views instead. While it's *possible* to implement the logic in the template, it (1) is inefficient and

Re: Seeing if a variable value is within a dictionary key value within a list of dictionaries

2012-09-08 Thread Jason
Hi guys, thank you for your responses. I think, following your advice, I'll have to abandon my attempts to handle this in the template, and sort this out in the views instead. Thanks again :) J On Saturday, September 8, 2012 7:40:39 PM UTC+1, Javier Guerra wrote: > > On Fri, Sep 7, 2012 at

Re: Seeing if a variable value is within a dictionary key value within a list of dictionaries

2012-09-08 Thread Javier Guerra Giraldez
On Fri, Sep 7, 2012 at 6:19 PM, Tim Chase wrote: > On 09/07/12 16:06, Jason Whatford wrote: >> P.s. Tim, my data structure isn't that malleable. It's >> essentially I query my appengine datastore, and that retrieves a >> list of the data models, each of which can

Re: Seeing if a variable value is within a dictionary key value within a list of dictionaries

2012-09-07 Thread Tim Chase
On 09/07/12 16:06, Jason Whatford wrote: > P.s. Tim, my data structure isn't that malleable. It's > essentially I query my appengine datastore, and that retrieves a > list of the data models, each of which can be treated as a dict. > The dicts are used in a few different ways in the view - only >

Re: Seeing if a variable value is within a dictionary key value within a list of dictionaries

2012-09-07 Thread Craig Amundsen
I see it now. private_datails is not a dictionary. It's a list of dictionaries where each dict has one key-value pair. How about this: private_ids = [x.values()[0] for x in private_details] if folder.id in private_ids or if you want it one line: if folder.id in [x.values()[0] for x in

Re: Seeing if a variable value is within a dictionary key value within a list of dictionaries

2012-09-07 Thread Jason Whatford
Hi Craig, thanks for the response. I'm using django 1.2 for templating and webapp2 to handle the requests on appengine. I've tried your suggestion of {% if folder.id in private_folder_details.values() %} as well as {% if folder.id in private_folder_details.values %} But it prevents page

Re: Seeing if a variable value is within a dictionary key value within a list of dictionaries

2012-09-07 Thread Craig Amundsen
{% if folder.id in private_folder_details.values() %} should do the trick On Fri, Sep 7, 2012 at 11:06 AM, Jason <1jason.whatf...@gmail.com> wrote: > Hi there, > > I'm using django 1.2 and am attempting to get the following code to work. > > private_folder_details = [{"folderId":"", "name":

Re: Seeing if a variable value is within a dictionary key value within a list of dictionaries

2012-09-07 Thread Tim Chase
On 09/07/12 13:06, Jason wrote: > I'm using django 1.2 and am attempting to get the following code to work. > > private_folder_details = [{"folderId":"", "name": "The folder > name"},{"folderId":"1221", "name": "The other folder name"}] > private_folders = [{"id":""},{"id":""}] > >

Seeing if a variable value is within a dictionary key value within a list of dictionaries

2012-09-07 Thread Jason
Hi there, I'm using django 1.2 and am attempting to get the following code to work. private_folder_details = [{"folderId":"", "name": "The folder name"},{"folderId":"1221", "name": "The other folder name"}] private_folders = [{"id":""},{"id":""}] {% for folder in private_folders %}