Want to compare(if they are same or not) 'map_id' of 'map' model with 'uni_id' of 'Uni' model, return if they are same. Note: models map and Uni are also in different databases.
Below are the two models:
class map(models.Model):
job_id = models.AutoField(db_column='job_id', primary_key=True)
company = models.CharField(max_length=255, blank=True, null=True)
map_id = models.CharField(db_column='Map_ID', max_length=255, blank=True, null=True)
class Meta:
managed = True
db_table = 'Map'
class Uni(models.Model):
uni_id = models.BigAutoField(db_column='Uni_ID', primary_key=True)
comp_name = models.TextField(blank=True, null=True)
name = models.TextField(blank=True, null=True)
class Meta:
managed = True
db_table = 'Uni'
I want to filter map_id from map model whose value is equal to uni_id from Uni. below is the code which i tried:
obj_map = map.objects.using("Map").filter(map_id=pk).filter(map_id__in=F('uni_id'))