Django-Crontab - Collecting Data with Scheduled Functions in Django

Описание к видео Django-Crontab - Collecting Data with Scheduled Functions in Django

In this video, we will use django-crontab package to collect cryptocurrency data from an API every minute, and store that data in the database.

django-crontab allows you to schedule functions - schedules can be as flexible as you like, for example "every minute", "every day at midnight", "every Sunday at 4pm" etc.

We will use Docker in this video, as django-crontab does not work on Windows systems. We'll also use django-environ to read in sensitive environment variables (i.e. the API key), and use HTMX polling to display our real-time updates on the web page without a refresh.

Data will be collected every minute with our django-crontab function, stored in the database, and displayed on the webpage with HTMX polling for automatic updates every time the cronjob runs.

☕️ 𝗕𝘂𝘆 𝗺𝗲 𝗮 𝗰𝗼𝗳𝗳𝗲𝗲:
To support the channel and encourage new videos, please consider buying me a coffee here:
https://ko-fi.com/bugbytes

📌 𝗖𝗵𝗮𝗽𝘁𝗲𝗿𝘀:
00:00 Intro
01:18 Setup
02:46 Docker Overview
04:45 Using django-environ to add settings
06:14 Starting django app using docker
07:21 Testing API with Django shell
11:00 Creating database models
13:13 Creating django-crontab function
18:40 Adding cronjobs settings
23:55 Displaying price data on page
25:53 Adding HTMX polling for data updates
31:32 crontab.guru for cron expressions

𝗦𝗼𝗰𝗶𝗮𝗹 𝗠𝗲𝗱𝗶𝗮:
👾 Github: https://github.com/bugbytes-io/django...
📖 Blog: https://www.bugbytes.io/posts/creatin...
🐦 Twitter:   / bugbytesio  

📚 𝗙𝘂𝗿𝘁𝗵𝗲𝗿 𝗿𝗲𝗮𝗱𝗶𝗻𝗴 𝗮𝗻𝗱 𝗶𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻:
Starter Code: https://github.com/bugbytes-io/django...
Docker installation: https://docs.docker.com/get-docker/
django-crontab: https://pypi.org/project/django-crontab/
CoinMarketCap API: https://coinmarketcap.com/api/
CoinMarketCap Authentication: https://coinmarketcap.com/api/documen...
CoinMarketCap sample response: https://coinmarketcap.com/api/documen...
blog post: https://www.bugbytes.io/posts/creatin...
django-environ: https://django-environ.readthedocs.io...
crontab.guru: https://crontab.guru/
docker 'exec' command: https://docs.docker.com/engine/refere...

#python #django #cronjobs #htmx

Комментарии

Информация по комментариям в разработке