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
w.regionis the linked region row, so any attribute in the region model can be accessed through it. So if your region model had aname, you would dow.region.name, and its the same withw.district.w.region.planis the row in the plan table that has a foreign key to the region row that is linked to the weather object with the primary key of 1;w.district.planworks the same way.To filter:
Yes, read the documentation on aggregation.