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 the
model, e.g. using "sponsor"
qs=DinnerHost.objects.exclude(sponsor=False)

But I want to use the model definition, along the lines suggested by
(but does not work) to get all the completed hosts:

qs=DinnerHost.objects.filter(complete=True)
and tried
gs=DinnerHost.objects.filter(complete()=True

What is the right nomenclature to get this?

Thanks

===========


Backup:

class DinnerHost(models.Model):
    member = models.ForeignKey(Member, null=True,
db_column='memberid', related_name="hosts", blank=True)
    meeting = models.ForeignKey(Meeting, null=True,
db_column="meetingid", related_name="hosts", blank=True)
    host = models.CharField(max_length=300, db_column='Host',
blank=True)
    sponsor = models.BooleanField(db_column='Sponsor', blank=True)

    def complete(self):
    # rules for what makes a complete booking
        if self.sponsor and self.isadreceived and self.isfullybooked:
            return True
        if not self.sponsor and self.isfullybooked:
            return True
        return False

    objects = models.Manager()


Note;
1. not all fields show, for simplicity
2. isfullybooked and isadreceived are both Model methods.

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