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 updated on Save.  While initially thought to be a
good idea I changed my mind because:
1.  reqireired running the Python/Django program to update ... yet
some of the data in the db gets update via many other tools and so
there will be an consistency issue.
2.  writing a stored procedure to update in MysQL ... too complicated
3.  doing it as a batch update in Python/Django ... means hitting all
the records and then sort of messes up the value of the timestamp on
each record.  I'd rather that timestamp mean something more real than
that.
4.  add a related table which does this computation (fixing problem
3) ... too complicated

in the end what I did was in the program where I want to do something
with the "not complete" records, I write a small routine in the
program that extracts a query set with all records, then loops through
all records and finds where, using the Model definition, "if not
h.complete():" where "h" is the record from the loop in the query set.
Then I just append to a list the ID of that record.  Then i re-query
the database for those records where ID is in the list.

Works.  understandable for those who follow, etc.  No db changes and
no added maintenance.

 
hosts1=DinnerHost.objects.all().filter(year__exact=CURRENT_YEAR)
            tablelist=[]
            for h in hosts1:
                if not h.complete():
                    tablelist.append(h.tablename)
 
hosts2=DinnerHost.objects.filter(year__exact=CURRENT_YEAR).filter(tablename__in=tablelist)

Now hosts2 has what I want.

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