Re: Query Set involving Model Method

2011-01-17 Thread rmschne
Much thanks to all. I could not get something like: gs=DinnerHost.objects.all().filter(complete()=True to work. probably think fingers on my side to get the nomenclature write; but I suspect not possible. While I liked the idea of computing a new field "complete" in the database which is

Re: Query Set involving Model Method

2011-01-16 Thread Ian Clelland
On Sun, Jan 16, 2011 at 6:51 AM, Mikhail Korobov wrote: > It doesn't work that way. ORM translates you queries to SQL and the DB > is responsible for filtering. It is not possible to translate > arbitrary python function to SQL or pass it to DB engine. So you have > to

Re: Query Set involving Model Method

2011-01-16 Thread Matteius
try: gs=DinnerHost.objects.all().filter(complete()=True objects by default doesn't select anything, so either use objects.get(pk=var_pk) or the a-typical case all(). -Matteius On Jan 16, 7:04 am, rmschne wrote: > Following is an extract of a Model I'm using.  I'd like to be

Re: Query Set involving Model Method

2011-01-16 Thread rmschne
Mikhail, Thanks. I like that idea. Simple and understandable for those who follow me. On Jan 16, 2:51 pm, Mikhail Korobov wrote: > It doesn't work that way. ORM translates you queries to SQL and the DB > is responsible for filtering. It is not possible to translate >

Re: Query Set involving Model Method

2011-01-16 Thread Mikhail Korobov
It doesn't work that way. ORM translates you queries to SQL and the DB is responsible for filtering. It is not possible to translate arbitrary python function to SQL or pass it to DB engine. So you have to formulate you query using .filter syntax or raw SQL. Another possibility is to denormalize

Re: Query Set involving Model Method

2011-01-16 Thread rmschne
Thanks. I'm still messing with this; but don't think it quite what I'm looking for. I want/need the Model Definition function complete() for use at the record level. I did this as a function since the rules are not based simply on the value of the fields. Ideally, I'd like to have the class

Re: Query Set involving Model Method

2011-01-16 Thread aid
Hi, On Jan 16, 1:04 pm, rmschne wrote: > qs=DinnerHost.objects.filter(complete=True) > and tried > gs=DinnerHost.objects.filter(complete()=True Try something along the lines of, class DinnerHostManager(models.Manager): def complete(self): return self.filter(

Query Set involving Model Method

2011-01-16 Thread rmschne
Following is an extract of a Model I'm using. I'd like to be able to query it to get a query set return that uses one of the Model Definitions, e.g. get all the Hosts where "complete=True" where 'complete' is a model definition. I know the nomenclature to use when exclude/include on a field in