I want to write queryset across 3 tables. (models are shown as below)
As outcome, I want to get below information.
{"naming1":"lpd1","naming2":"lpd2",...}
Can anyone tell me how to write this query?
models.py
class zone(models.Model):
zone=models.CharField(max_length=20)
def __str__(self):
return self.zone
class light(models.Model):
zone=models.OneToOneField(zone, primary_key=True, on_delete=models.CASCADE)
lpd=models.IntegerField() <=extract
class naming(models.Model):
zone=models.ForeignKey(zone)
naming=models.CharField(max_length=20) <=extract