Suppose I have something like this in my models.py:
class Hipster(models.Model): name = CharField(max_length=50) class Party(models.Model): organiser = models.ForeignKey() participants = models.ManyToManyField(Profile, related_name="participants")
Now in my view.py I would like to make a request that will receive a batch for a user with more than 0 members.
Something like this could be:
user = Hipster.get(pk=1) hip_parties = Party.objects.filter(organiser=user, len(participants) > 0)
What is the best way to do this?
django django-models django-queryset
Ska Oct 25 '11 at 2:01 2011-10-25 02:01
source share