| layout | default |
|---|---|
| title | 🚀 django-crontask - Schedule Django Tasks Easily |
| description | 🌟 Schedule recurring asynchronous tasks in Django effortlessly with cron-style syntax and lightweight helpers built on APScheduler. |
django-crontask is a cron-style scheduler for Django's task framework. It allows you to automate routine tasks in your Django projects. Whether it's sending emails, cleaning up databases, or running data backups, django-crontask makes it simple to set up and manage scheduled tasks.
- Simple Scheduling: Set tasks to run at specified times using easy-to-understand syntax.
- Django Integration: Works seamlessly with Django's existing task framework.
- Flexible Options: Customize scheduling to fit your project needs.
- User-Friendly: Designed for users with no programming experience.
- cron
- cronjob
- crontab
- django
- tasks
Before you begin, ensure you have the following:
- A machine running Windows, macOS, or Linux.
- Python installed (version 3.6 or above).
- A Django project set up.
Visit this page to download: Releases Page.
Click on the latest version to download the installer.
Once you've downloaded the installer, follow these steps:
- Locate the downloaded file in your downloads folder.
- Double-click the file to run the installer.
- Follow the on-screen instructions to complete the installation.
After installation, you need to configure django-crontask in your Django settings:
- Open your Django project directory.
- Go to the
settings.pyfile. - Add
django_crontaskto yourINSTALLED_APPSlist.
INSTALLED_APPS = [
... # Your existing apps
'django_crontask',
]- Save the changes.
To create a scheduled task, follow these steps:
- Navigate to your Django project directory.
- Create a new Python file (e.g.,
tasks.py). - Define your task function:
from crontask import Crontask
@Crontask('*/15 * * * *') # Runs every 15 minutes
def my_scheduled_task():
# Your task code here
print("Task is running!")- Save the file.
To run the scheduler, use the following command in your terminal:
python manage.py crontaskThis command starts the scheduler, and your tasks will run according to the configured timings.
- Documentation: Explore detailed documentation for advanced features and options.
- Support: Join the community forums for help and support.
- Task Not Running: Check your cron syntax. Ensure it follows the correct format.
- Django Errors: Review the task function for any coding mistakes.
- Permissions Issues: Make sure that your user has the necessary permissions to run cron tasks.
If you encounter any issues, you can reach out for help on the GitHub issues page. Describe your problem clearly, and the community will assist you.
With django-crontask, managing scheduled tasks in your Django applications is straightforward. Follow the steps above to get started quickly. Enjoy automating your tasks!