Thank you!
On Jan 30, 11:42 am, Tim Chase <[EMAIL PROTECTED]> wrote:
> > I'm new to python and django and I'm trying to do dynamic queries.
> > Can't quite get it to work right, however. This is what I'm trying to
> > do.
>
> > field = "desc"
> > query = User.objects.filter( field = "john")
>
> > but meaning `field` the variable, not the column. I don't think that
> > python does that, then what do i do to get dynamic column names?
>
> You can use dictionary keyword args[1]:
>
> params = {'desc': 'john'}
> query = User.objects.filter(**params)
>
> Thus, you can build the params dictionary with whatever
> variable-names you want.
>
> -tim
>
> [1]http://www.python.org/doc/current/tut/node6.html#SECTION0067200000000...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---