I want to perform some one-time operations such as to start a background thread and populate a cache every 30 minutes as initialize action when the Django server is started, so it will not block user from visiting the website. Where should I place all this code in Django?
- Put them into the setting.py file does not work. It seems it will cause a circular dependency.
- Put them into the
__init__.py
file does not work. Django server call it many times (What is the reason?)