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/14/django-implied-relationship/ On Mon, Mar 7, 2022 at 5:43 PM dans...@gmail.com <dansm...@gmail.com> wrote: > Hi guys, > > I remember that there is a new way to declare constraints in class Meta on > a model, and that this is preferable for unique_together constraints. > > I've long wanted a way with Django to have database foreign key > constraints cascade in the database rather than via Django. Is there now > a way to do this? > > Thanks! > > -- > You received this message because you are subscribed to the Google Groups > "Django developers (Contributions to Django itself)" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-developers+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-developers/3e28c4b0-896d-49fa-b768-a30c3db96c23n%40googlegroups.com > <https://groups.google.com/d/msgid/django-developers/3e28c4b0-896d-49fa-b768-a30c3db96c23n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAMyDDM3eDEX%2B4GbLco0zU%3D5SFmfLMXgNBOqQC-N6Nj%3Dk3CtK-A%40mail.gmail.com.