Django finding which field matched in a multiple OR query
- by Greg Hinch
I've got a couple models which are set up something like this:
class Bar(models.Model):
baz = models.CharField()
class Foo(models.Model):
bar1 = models.ForeignKey(Bar)
bar2 = models.ForeignKey(Bar)
bar3 = models.ForeignKey(Bar)
And elsewhere in the code, I end up with an instance of Bar, and need to find the Foo it is attached to in…