The title contains the question - I want to send weekly emails in my Django app. Where should the code that pulls the data from the database and sends the email message live? I have seen examples of code that sends emails, such as this and this, but it is not specified in which file it resides and what's its relationship to the rest of the Django elements.
Asked
Active
Viewed 164 times
1
-
https://stackoverflow.com/questions/3295268/where-should-utility-functions-live-in-django – Rahul Nov 03 '20 at 14:20
1 Answers
2
Well, this really depends on the purpose of your email-sending script. It's completely up to you.
But if it is supposed to be a complex code that is used to periodically send emails with data from multiple django apps' models in database, I would suggest making a separate app for it. There you can also define your complete logic behind the periodical sending.
On the other hand, if it is supposed to be a simple while cycle / cron-based job used for one app's purposes, it can be a single file inside of the corresponding app's directory (send_newsletter.py).

Johnny
- 40
- 8