I am new to django and have been working on a project where i need to send regular mails to my clients from different modules in my django project.
I wanted to know if there is any provision in django using which i can create a reusable component which can be used globally in my project.
The purpose is to create a mail sending function using a third party api and to call it from anywhere in my application just by passing the required parameters.
Assuming that you have a single django app in your project, you could define all your reusable methods inside a methods.py
file in your app folder and then import it to use the functions.
If you have multiple apps, Then define create this methods.py
in one of your app. Now lets say your project name is coolprojectname
and the name of app which has methods.py
is appwithmethodsscript
, then you can use
from coolprojectname.appwithmethodsscript import methods
Reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With