In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article is to share with you about how to use celery to achieve a scheduled task in django, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
The first step is to install celery and django-celery.
To switch between your project's python virtual environment, execute the following command to install the dependencies required by the project:
Pip install-r requirements.txt
After the dependency installation is successful, configure celery.
1. Create a celery.py file in the project root directory
two。 Write the configuration of celery in _ _ init__.py in the root directory of the project
3. Configure celery in setting.py
4. Create a tasks.py file under an application
5. Execute the database synchronization command to generate the data table corresponding to celery.
Python manage.py migrate
6. Log in to the admin backend of django, configure scheduled tasks, and select Periodic tasks
7. Change the celery source code, as shown in the following figure, part of the code
If you do not comment, you will bear the consequences.
8. On the command line, enter celery to run the command:
Python manage.py celery worker-loglevel=info-beat
The above is how to use celery to achieve a scheduled task in django. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.