I have two models in django :
class Matching(models.Model):
representative_remote_id = models.CharField(max_length=200, null=True)
representative_name = models.CharField(max_length=200)
representative_group = models.CharField(max_length=200)
class Vote(models.Model):
representative_name = models.CharField(max_length=200, blank=True, null=True)
representative_remote_id = models.CharField(max_length=200, blank=True, null=True)
# ...
As you can see, there are no relation between these two models. What I want is select all votes where :
vote.representative_name = CONCAT(matching.mep_name, ' (', matching.mep_group, ')')
AND matching.representative_remote_id IS NULL
AND vote.representative_remote_id IS NOT NULL
I can’t find a way to do this with django (without using 'raw' sql query)