samedi 30 juillet 2016

convert sql from multiple tables with subquery IN to django orm.

How can I convert this sql to django orm? Effectively.

select * from friend where party_id IN(select party_id from party where venue=venue123)


class Friend(models.Model):
    party = models.ForeignKey(Party, related_name='partyid')


class Party(models.Model):
    venue = models.ForeignKey(Venue, related_name='venueid')


class Venue(models.Model):
    venue_name = models.CharField(max_length=33, default='')

Aucun commentaire:

Enregistrer un commentaire