How to join the results of two tables in django python
- by user1787524
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