Hi Folks,

Is it possible to have dynamic db api lookups? In other words, I want
to be able to generate a get_list statement conditionally based on some
user options. For example:

Here's what I'm currently doing:

if status:
        object_list = logs.get_list(
            timestamp__year = d.year,
            timestamp__month = d.month,
            timestamp__day = d.day,
            status__exact = status
        )
    else:
        object_list = logs.get_list(
            timestamp__year = d.year,
            timestamp__month = d.month,
            timestamp__day = d.day,
        )

Which is clunky but works okay, but what about if I have three other if
statements for other variables? Do I nest those in, or is there some
way to create a list or dictionary that holds all my lookup variables
(let's call it lookup_variables) and then I can just append to it and
then call it with:

object_list = logs.get_list(lookup_variables)

Thanks, Tom


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@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-developers
-~----------~----~----~----~------~----~------~--~---

Reply via email to