On 10 jan, 18:56, rabbi <alex.averb...@gmail.com> 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?

Nowhere.

> Is it part of MyModel or somewhere else?

Nope, it's only a keyword argument - nothing else than a litteral
name, really. As Christian already mentioned, the solution here is to
build the name as a string, use this string as a key in a dict, then
pass the dict to filter using the **youdicthere calling convention.
You can read the Python tutorial's part on function arguments and
function calls for more in-depth explanations.


--~--~---------~--~----~------------~-------~--~----~
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