[Fixed]-How to ensure that two foreign keys both belong to the same user

1👍

Try Django Smart Selects we use them in our project to solve that exact problem

0👍

You can try to find a workaround with unique_together (https://docs.djangoproject.com/en/dev/ref/models/options/#unique-together) by overriding it for your special needs.

But it might not be easy: Django Unique Together (with foreign keys)

But it’s never wrong to check values before insert 😉

0👍

Maybe teacher should be a separate class, and teacher in Task class should be related with teacher from Student class. Maybe usage the through argument is option for it.

Leave a comment