I'm part of the way working through a solution for this for MySQL. I just
need to finish off the tests and documentation then it will be up on GitHub
I just had to put it on hold but it fixes an issue in MySQL 5.7+ for Django
that otherwise occurs if the database you are using is used by anythin
If you're interested in following the development of the database level
foreign key constraints feature you should CC to #21961 [0]
The latest attempt at implementing them was recently closed due to
inactivity [1]
Cheers,
Simon
[0] https://code.djangoproject.com/ticket/21961
[1] https://github
No, there is not currently a way in Django to declare such constraints. You
can always create them in a migration using the RawSQL operation, then rely
on them in your code.
This blog post relates to custom relationships which would allow you to
model them, I think:
https://schinckel.net/2021/07/1