I’m working in django project. I have 1 postgresql sql file that need to run only one time after db created. Built-in django signal not quite suit with my case. So I try to write custom django signal but I’m not sure how to start with this case. Does anyone has a good guide. ? 🙂
Share
The Django docs on signals have improved dramatically, so take a look there if you haven’t already. The process is pretty simple.
First create your signal (
providing_argslets you specify the arguments that will get passed when you send your signal later):Second, create a receiver function:
Finally, send your signal wherever you like in your code (
selfas sender is only applicable within your model class. Otherwise, just pass a the model class name):