I need my Django app processing some functions in background periodically. What is the best way for making such functions? And how can I call some functions when server starts? For example, functions of pre-init.
For periodical jobs, you can try Django RQ Scheduler .
As for running functions at runtime, you can place the code in any models.py file or in apps.py like following
from django.apps import AppConfig
class FooConfig(AppConfig):
name = 'foo'
def ready(self):
# import here and do logic
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.