Sure: http://docs.python.org/tutorial/controlflow.html#unpacking-argument-lists

myfilter = { var_field: "found" }
Foo.objects.filter(**myfilter}

hth,
Nuno

On Fri, May 14, 2010 at 2:19 PM, derek <gamesb...@gmail.com> wrote:
> Given a model Foo, with a field bar:
> Foo.objects.filter(bar = "found")
> works just fine.
>
> But, in my case, different fields are needed at different times, so I
> would like to use:
> Foo.objects.filter(var_field = "found")
> where "var_field" is a variable which will be set to the name of a
> field (such as "bar").
>
> The above is incorrect - how do I accomplish this?
>
> Thanks
> Derek
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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.

Reply via email to