Re: For any dictionary in a list, does a value exist for a key?

2011-04-19 Thread bruno desthuilliers
On 18 avr, 18:27, Shawn Milochik wrote: > You can do this pretty easily in Python with any(): > > if any(['foo' in x for x in my_list]): >     #do something should be: if any(x['id'] == 'foo' for x in mylist): do_something() Your above snippet will test if a dict in

Re: For any dictionary in a list, does a value exist for a key?

2011-04-19 Thread Chris Roat
Yep - trying to do it in a template. I can just do the logic within in python - it'll mean redundant info going into the template, but that's OK. Thanks for your response, C On Mon, Apr 18, 2011 at 9:27 AM, Shawn Milochik wrote: > You can do this pretty easily in Python

Re: For any dictionary in a list, does a value exist for a key?

2011-04-18 Thread Shawn Milochik
You can do this pretty easily in Python with any(): if any(['foo' in x for x in my_list]): #do something However, I don't know of a way to do it in a template, which is what it appears you're asking. -- You received this message because you are subscribed to the Google Groups "Django

For any dictionary in a list, does a value exist for a key?

2011-04-18 Thread Chris Roat
Does a function or construct exist to easily do the following? my_list = [{'id': 'foo'}, {'id': 'bar', 'other': 'baz'}] {% is my_id_value in my_list.id %} // True if my_id_value is 'foo' or 'bar' Thanks! -- You received this message because you are subscribed to the Google Groups "Django