Skip to main content

django-redis-aiogram

PyPI Python CI License

Run aiogram next to Django: write handlers as ordinary Django app code, and send Telegram messages from anywhere in the project.

One container runs the bot. Every other process — web, Celery, a management command — pushes the call onto a Redis list and returns, so a request never waits on Telegram.

  web, celery  ──bot.send()──▶  Redis list  ──▶  start_tgbot  ──▶  Telegram

Install

pip install django-redis-aiogram
# settings.py
import os

INSTALLED_APPS = [..., 'django_redis_aiogram']

TELEGRAM_BOT = {
    'TOKEN': os.environ.get('TELEGRAM_BOT_TOKEN', ''),
    'REDIS_URL': os.environ.get('REDIS_URL', ''),
}

Both may be empty. Nothing connects or validates credentials at import time, so tests and migrations run without them. Requires Python 3.10–3.14, Django 5.2+, aiogram 3.30+, redis 6.2+.

Use it

# myapp/tg_router.py — imported automatically from every installed app
from aiogram import F, types

from django_redis_aiogram import bot


@bot.message(F.text == '/start')
async def start(message: types.Message) -> None:
    await message.answer('hi')
# anywhere else in the project
from django_redis_aiogram import bot

bot.send(chat_id=CHAT_ID, text='Order approved')
python manage.py start_tgbot

A router module, a call, and one process running the bot. Everything else — rate limits, per-process opt-out, healthchecks — is configuration, and it is documented rather than required. Webhook mode is the one alternative that also asks for a URL route; Webhook has the four steps.

Documentation

The wiki is the documentation. Pages live in docs/wiki/, so they are reviewed in the same pull request as the code they describe and published from master.

Installation install, configure, run
Settings every setting, with defaults and check ids
Handlers routers, filters, FSM, the async ORM
Sending messages routes, keyboards, files, errors
Testing your suite without Redis, asserting what was queued
API the instance, its internals, and what stays public
Delivery how queued messages reach Telegram
Webhook receiving updates over HTTP instead of polling
Rate limits staying inside Telegram's published limits
Deployment compose recipes, healthchecks, per-process opt-out
Logging the logger and its structured fields
Event log recording what the bot did to a table
Serialization what can be queued
Troubleshooting symptoms and their usual causes
Upgrading what each major release changed, and what you must do
AI assistants the brief to hand a coding agent

Upgrading to 3.0: the deprecated telegram_bot package name is gone, so INSTALLED_APPS and imports have to name django_redis_aiogram. The upgrading page lists everything else that needs attention.

Contributing

CONTRIBUTING.md for the workflow, AGENTS.md for the same ground in the form coding agents read. Changes are in CHANGELOG.md; security reports go through SECURITY.md.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_redis_aiogram-3.0.0.tar.gz (157.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_redis_aiogram-3.0.0-py3-none-any.whl (85.0 kB view details)

Uploaded Python 3

File details

Details for the file django_redis_aiogram-3.0.0.tar.gz.

File metadata

  • Download URL: django_redis_aiogram-3.0.0.tar.gz
  • Upload date:
  • Size: 157.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for django_redis_aiogram-3.0.0.tar.gz
Algorithm Hash digest
SHA256 d426d6c3590c51ff3fb81e8e231231f2c3487e3b5d9c73ee2571844e2ec86c56
MD5 9d9297c8ffb609a31979e66425bcb563
BLAKE2b-256 6716fc85f9e662f88fba43e753c32ea7b03e0e8c0f1c0e40dd106b1962ba4d9b

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_redis_aiogram-3.0.0.tar.gz:

Publisher: publish.yml on CorneiZeR/django-redis-aiogram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_redis_aiogram-3.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_redis_aiogram-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4f62a1a53e60552100211062ac5cca2ba719a624631b32ae862a8ea29e767b10
MD5 f6814f62061d0f5a9fa14cdef533165f
BLAKE2b-256 6a011bb544b1119afca5ed1cad1891c57d7f1db0eb098a3127f61f537d9565b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_redis_aiogram-3.0.0-py3-none-any.whl:

Publisher: publish.yml on CorneiZeR/django-redis-aiogram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

3.1.0

2 files

This release

3.0.0 This release

2 files

2.2.0

2 files

2.1.1

2 files

2.1.0

2 files

2.0.1

2 files

2.0.0

2 files

1.0.8

2 files

1.0.7

2 files

1.0.6

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page