Django-CRON is a project aimed at setting up and running cron jobs in a Django application using Docker. This repository provides the necessary scripts and instructions to get your Django cron jobs up and running.
- Easy setup of virtual environments for both macOS/Linux and Windows
- Docker integration for managing Django migrations and creating superusers
- Instructions for running cron jobs within the Django application
- Python 3.x
- Docker
python3 -m venv env
source env/bin/activate
python -m venv env
env\Scripts\activate
docker compose up --build
//open another terminal and then:
docker exec -it cron_Django python manage.py makemigrations
docker exec -it cron_Django python manage.py migrate
docker exec -it cron_Django python manage.py createsuperuser
Go to http://localhost:5050/ Enter these credentials and press the Login button: Email Address / Username: [email protected] Password: admin123 Right click on Servers and then Register > Server In General tab, enter Name: testCRON In Connection tab, enter these details and click Save Host name/address: cron_Postgres Username: postUser Password: password Then go to Servers > testCRON > Databases > cron_db > Schemas > public > Tables To view table click on View/Edit Data > All Rows
To run cron jobs, go to the manage.py
directory and run these commands:
# Install dependencies **run this from the root directory** pip install -r requirements.txt
file_path = "C:/Users/User/Downloads/KayakTransactionReport.csv" output_file = "C:/Users/User/Downloads/ProcessedReport.csv"
cd cron_project python manage.py runcrons
python manage.py shell
from import_export.cron_jobs import FileProcessingCronJob
cron = FileProcessingCronJob() cron.do()
exit()