Joining two tables in ORM Django -
there 3 models person, author , singer.
class person(models.model): name = models.charfield(max_length=256, null=true) class meta: db_table = "person" class author(models.model): person = models.foreignkey(person) rating = models.inegerfield(null=true) class meta: db_table = "author" class singer(models.model): person = models.foreignkey(person) rating = models.integerfield(null=true) class meta: db_table = "singer"
i have perform joining between author , singer in orm
mysql select s.* singer s join author on s.person_id=p.person_id;
the simpler solution according database model be
author_objects = author.objects.filter(person=singer_object.person) # singer_object # author_objects
Comments
Post a Comment