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

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -