I like the changes in Django 5.0 that expose more database functionality - database defaults and generated fields. Is there any interest in adding some support in Django for database triggers? As I understand it, currently triggers in an app would have to be created/maintained with raw SQL commands.
I know there’s a third-party package, but would anyone like to see built-in support?
New features such as this are recommended as being created as third-party packages precisely to see how well they function and what the level of interest may be. It also allows for faster development cycles while the kinks are being worked out.
If you’re really interested in seeing something like this in core, then the best thing you can do is use it yourself, and help prove that it is a viable and valuable option.
The development and usage of third-party packages is encouraged, by design and intent, for precisely this purpose.
Ken is absolutely right. I’d also say that Django keeps its database feature set compatible with multiple backends. Meanwhile triggers have a lot of backend-specific restrictions and features. A design for Django core would need to be both universal and flexible, a challenge.
Yeah I agree that django-pgtrigger is a great way to test the waters… I use it myself and agree it should remain a 3rd party package. (Wesley Kendall has done an awesome job with it)
What it does show however is that having official support for extending & customising
Meta as a desired feature. At the moment pgtrigger patches meta, migrations etc to get the
Meta.triggers attribute to function correctly: https://github.com/Opus10/django-pgtrigger/blob/master/pgtrigger/apps.py
Reminds me of #5793 (Allow custom attributes in Meta classes) – Django
Thanks for your replies. Yeah, it would be nice if pgtrigger didn’t have to patch things in Django.