BTW: The code worked without editing.  :-)

Thanks.

On Sun, Nov 10, 2013 at 6:23 AM, Timothy W. Cook <t...@mlhim.org> wrote:
> On Sat, Nov 9, 2013 at 11:37 PM, donarb <don...@nwlink.com> wrote:
>>
>> The better way is to use the database to find the values, rather than doing
>> it in Python.
>
> Okay, this is good information to know.
>
> Off the top of my head, I'd do something like this:
>>
>> def get_context_data(self, **kwargs):
>>     context = super(IndexView, self).get_context_data(**kwargs)
>>
>>     # Get all active managers from the database
>>     q = Manager.objects.filter(expires__gte=now())
>>
>>     # Create a list of all of their email addresses, the values() and
>> values_list() methods
>>     # can pull out just the fields you want - 'flat' creates a list rather
>> than a dict or tuple
>>     mlist = q.values_list('user__email', flat=True)
>>     context['mgr_list'] = mlist
>>     return context
>>
>
> More good info there.  Thanks.
>
>
>> As I said, I haven't tested this and I may be buggy, but you should be able
>> to get the idea.
>>
>
> ...
>
>> Um, I'm definitely not buggy, but my sample may be...
>
> LOL!  Are you sure you aren't?
>
> I have quite buggy (thinking) at times. But it makes life more interesting.  
> :-)
>
> Thanks again.
>
> Cheers,
> Tim



-- 
MLHIM VIP Signup: http://goo.gl/22B0U
============================================
Timothy Cook, MSc           +55 21 94711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3ViRD0TMaL%3DV3w_GZfD1xof3CMwiwXcKxZG%2Bd9XFdnwvg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to