> subtasks = tasks.exclude(part_of__exact='None') > returns the correct subset, with the "top" tasks omitted. Why?
'None' is a string, so if anything, you'd have to use: part_of__exact=None However, what you're looking for is probably: subtasks = Task.objects.filter(part_of__isnull=True) Michael [EMAIL PROTECTED] schrieb: > Why does hitting TAB (nervous emacs autoindent twitch) complete a > post being edited??? Anyhow, here's the full question This could be > elementary... In a model: > > class Task(models.Model): ... part_of = models.ForeignKey('Task', > null=True, blank=True, related_name='subtasks') ... > > I am trying to do a query (after having a number of tasks and > subtasks entered: > > tasks = Task.objects.all() toptasks = > tasks.filter(part_of__exact='None') > > to find tasks that are "not part of another", e.g. they are not > "subtasks". This always returns an empty set However: > > subtasks = tasks.exclude(part_of__exact='None') > > returns the correct subset, with the "top" tasks omitted. Why? > > On Feb 7, 12:06 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> > wrote: >> This could be elementary... In a model: >> >> class Task(models.Model):t > > --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---