I think this should work: Profile.objects.filter(services__creator__isnull = True)
If you query like this and one of the intermediate models doesn't exist then django will treat that model as if it did exist but with all of it's values as null. That is as I understand it anyway! On Nov 10, 9:24 pm, Eduardo Robles Elvira <edu...@gmail.com> wrote: > Hello everyone, > > I'm trying to do this: > > ..... > from user.models import Profile > Profile.objects.filter(services__count=0) > ..... > > As you can see, I want to retrieve all the users with no related > services. But it gives an error: "FieldError: Cannot resolve keyword > 'count' into field. Choices are: blah blah.." > > The services field is generated in the model Services as a related > foreign key: > > class Service(models.Model): > creator = models.ForeignKey(Profile, related_name="services") > ..... > > Any way to do this the django-way? I'm using django 1.2.3. > > Thanks in advance, > Eduardo RE -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.