Consider following models:
class Model1:
x = an integer
y = an integer
class Model2:
f1 = models.ForeignKey(Model1)
f2 = models.ForeignKey(Model1)
Now, I want to put a constraint on model 2 such that no duplicate pairs of f1.x and f2.x get inserted in model 2.
How should I achieve it? I will be populating model 2 using bulk_create so maybe customising clean() or save() won't work.
I'm new to Django and not able to figure it out. Any help will be appreciated.
There another similar question here: How to define two fields "unique" as couple
But it's not helpful in my case.