Hi

Does anyone know if its possible to filter a queryset by the count of
it's foreignkey or manytomany set?

For example:

class Y(models.Model):
  name = models.CharField(...)

class X(models.Model):
  name = models.CharField(...)
  y_rec = models.ManyToManyField(Y)

class Z(models.Model):
  x = models.ForeignKey(X)

now I would like to:

X.objects.filter(z__count__gt = 0, y__count = 0)

--

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.


Reply via email to