Hi all, I have a situation here where I do not know how to use the filter() function in the database API to obtain a QuerySet. I am describing the schema and what I have done, below. I hope you have an answer to my question.
# Only the necessary fields are shown here class A(models.Model): pass class B(models.Model): a = models.ForeignKey(A) status = models.IntegerField('Status', blank=False) date = models.DateField('Date', blank=False) class Meta: get_latest_by = 'date' Whenever there is a change in the status of a row in table A, a new row is added to table B, to reflect that change. The latest row in table B corresponding to an A, represents the current status of that A. It is possible that there exists an A, which has no entry in table B. Now, what I want is a QuerySet of A's whose current status is 1. As of now, this is what I am doing: class ValidAsManager(models.Manager): """does not return a QuerySet""" def get_query_set(self): return (i for i in super(ValidAsManager, self).get_query_set() if i.status() == 1) class A(models.Model): objects = models.Manager() current_objects = ValidAsManager() def status(self): try: s = self.b_set.latest() return s.status except ObjectDoesNotExist: return 0 I am not able to use generic views for listing the valid A's because ValidAsManager does not return a QuerySet. Could someone tell me what I can do to return a QuerySet? How can I use the filter function to do so? If you feel my schema is incorrect, I can consider changing it. Thanks, Suriya --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---