rabbi wrote:
> Hi,
> I'm trying to write a generic filter function do something like
> following:
>    MyModel.objects.filter(   getattr(???,my_dict['search_field']
> +'__iexact')=my_dict['search_value']   )
> 
> But I don't know what to put in place of '???'
> Where does 'field__iexact' actually come from?
> Is it part of MyModel or somewhere else?

You don't need getattr:

MyModel.objects.filter(**{
   my_dict['search_field'] + '__iexact': my_dict['search_value']
})

I believe that will do the trick :)

Regards,
Christian

-- 
Christian Joergensen
http://www.technobabble.dk

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