Merging two fields from different table

10 views
Skip to first unread message

Kala Rani

unread,
Nov 4, 2022, 1:29:07 PM11/4/22
to Django users
My models.py

class Regions(models.Model):
 region_name = models.CharField(max_length=255)

 class Locations(models.Model): 
 region = models.ForeignKey(Regions, on_delete=models.CASCADE,blank=True,null=True) name = models.CharField(max_length=255)



How to do this query in django?

select locations.name,regions.region_name
  from locations
 inner join regions on locations.region_id = regions.id order by locations.name;


I want to show this Location name,Region name in v-select tag like 
location name-region name



Reply all
Reply to author
Forward
0 new messages