How to join the results of two tables in django python
Posted
by
user1787524
on Stack Overflow
See other posts from Stack Overflow
or by user1787524
Published on 2012-11-01T04:57:30Z
Indexed on
2012/11/01
5:00 UTC
Read the original article
Hit count: 145
I have two models
class Weather(model.model):
region = models.ForeignKey(Region)
district = models.ForeignKey(District)
temp_max = models.IntegerField(blank=True, null=True, verbose_name='Max temperature (C)')
temp_min = models.IntegerField(blank=True, null=True, verbose_name='Min temperature (C)')
and
class Plan(model.model):
name = tinymce_models.HTMLField(blank=True, null=True)
region = models.ForeignKey(Region)
district = models.ForeignKey(District)
Provided for every region and district have unique row. I want to combine the result so that i can get all the columns of both tables
These two Models are not related to each other. ' I need to make the join like
join weather w on w.region = A.region and w.distric = A.district
so that result contains all the columns in everyobject like
obj.temp_max etc
© Stack Overflow or respective owner