List Info

Thread: Run time lookups




Run time lookups
user name
2006-03-01 21:58:41
aaloy wrote:
> I'm trying to make a dynamic lookup filter depending
on the parameters
> that the user inputs on a web search.
>
> That is, I have three optional search fields and I
wan't to be able to
> make a lookup search on my database withot having to
code all the
> search options. Something like:
>
> search={}
> if searchcriteria1:
>     search['field1__exact']=searchcriteria1
> if searchcriteria2:
>     search['field2__contains']=searchcriteria2
> if searchcriteria3:
>     search['linkfield__id__pk']=searchcriteria3
>
> mytable.get_list(search)
>

Replace that last line with:

mytable.get_list(**search)

That should work if I'm not mistaking.

-janr


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Run time lookups
user name
2006-03-01 22:30:34
2006/3/1, Jan Rademaker <j.rademakergmail.com>:
>
> aaloy wrote:
> > I'm trying to make a dynamic lookup filter
depending on the parameters
> > that the user inputs on a web search.
> >
> > That is, I have three optional search fields and I
wan't to be able to
> > make a lookup search on my database withot having
to code all the
> > search options. Something like:
> >
> > search={}
> > if searchcriteria1:
> >     search['field1__exact']=searchcriteria1
> > if searchcriteria2:
> >     search['field2__contains']=searchcriteria2
> > if searchcriteria3:
> >     search['linkfield__id__pk']=searchcriteria3
> >
> > mytable.get_list(search)
> >
>
> Replace that last line with:
>
> mytable.get_list(**search)

I'll try thanks!

Actually what I have done is use the where keyword, but this
forces me
to use the real field names of the table and I don't like
very much. I
should be another, perhaphs more pythonic, solution to be
able to
create run time search conditions and pass them to the
django model.

--

Antoni Aloy López
Binissalem - Mallorca
Soci de Bulma

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Django users" group.
To post to this group, send email to django-usersgooglegroups.com
To unsubscribe from this group, send email to
django-users-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )