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, and a signal to count it without one
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.

Metadata

Release files for django-redis-aiogram 3.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-redis-aiogram 3.1.0
File Size Uploaded
django_redis_aiogram-3.1.0.tar.gz 392.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-redis-aiogram 3.1.0
File Interpreter ABI Platform
django_redis_aiogram-3.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 536.9 kB

Release files / django_redis_aiogram-3.1.0.tar.gz

Download URL django_redis_aiogram-3.1.0.tar.gz
Size 392.9 kB
Tags Source
SHA-256 checksum
How to use checksums
239c8514d03631e38a502e725a605b3055648032d22096a4291b76a6a40fe568
BLAKE2b-256 checksum
How to use checksums
1e7f128c90b5365cad20d86d16531a238ae80d029d50c006528bdea7f6033ee2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 21, 2026.

Transparency log

Release files / django_redis_aiogram-3.1.0-py3-none-any.whl

Download URL django_redis_aiogram-3.1.0-py3-none-any.whl
Size 144.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20edcd2e14a39b5efa786986c4e70dfc392d7365e9717a49721fadf623f4e642
BLAKE2b-256 checksum
How to use checksums
9b292e146abafa28fe7b5816a17b991d43b6423540418799ce2d2e21e5c0db9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 21, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

3.1.0 This release

2 release files

3.0.0

2 release files

2.2.0

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page