primitive wrote:
> Is it possible to use a string (coming from an request object) as a
> keyword to filter? I keep getting errors, but I don't know how to
> convert these strings into types that filter will understand.
Sure, Python allows you to pass a dict as a set of keyword arguments,
so you could do something like this (not tested, obviously):
def search(request):
if request['keyword'] and request['search']:
lookup = {'%s__icontains' % request['keyword']:
request['search']}
objs = MyModel.objects.filter(**lookup)
...
-Dave
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---