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 private_details] - Craig On Fri, Sep 7, 2012 at 2:06 PM, Jason Whatford <1jason.whatf...@gmail.com>wrote: > 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 loading i.e. breaks the page. According to > https://docs.djangoproject.com/en/1.2/ref/models/querysets/ it should > work, as you suggest. Any ideas? > > J > > 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 this is giving me trouble though. > > > On Fri, Sep 7, 2012 at 9:25 PM, Craig Amundsen <cdamund...@gmail.com>wrote: > >> {% 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":"1111", "name": "The folder >>> name"},{"folderId":"1221", "name": "The other folder name"}] >>> private_folders = [{"id":"1111"},{"id":"2222"}] >>> >>> {% for folder in private_folders %} >>> * {% if folder.id in private_folder_details %}* >>> <input type="checkbox" name="syncCheckbox" id="{{folder.id}}" >>> checked="yes" value="{{folder.id}}"> >>> {% else %} >>> <input type="checkbox" name="syncCheckbox" id="{{folder.id}}" >>> value="{{folder.id}}"> >>> {% endif %} >>> {% endfor %} >>> >>> Essentially if folder.id is within any of the private_folder_details >>> folderId's then I want the checkbox to be checked. What I'm doing above >>> doesn't seem to work though - any idea how it could be made to work? >>> >>> >>> -- >>> 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/-/6wVcQQxDg_sJ. >>> To post to this group, send email to django-users@googlegroups.com. >>> To unsubscribe from this group, send email to >>> django-users+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/django-users?hl=en. >>> >> >> -- >> 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+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/django-users?hl=en. >> > > -- > 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+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.