Skip to main content

Package to use Django ORM as persistence engine in Python Telegram Bot

Project description

python-telegram-bot-django-persistence

PyPI - Downloads All Contributors

Do you use python-telegram-bot or aiogram with Django and want storing FSM info without additional infrastructure?
We've got you covered!

Originally, this package supported only PTB, but we added aiogram, because it is awesome!

Quickstart

📥 Install package

If you are using poetry (and if not, please, consider using it 😉):

# For python-telegram-bot
poetry add "python-telegram-bot-django-persistence[ptb]"
# For aiogram
poetry add "python-telegram-bot-django-persistence[aiogram]"

Elif you are using pip, then just enter:

pip install python-telegram-bot-django-persistence

🔌 Add the app to your Django project

Then add python_telegram_bot_django_persistence into your INSTALLED_APPS in your settings file, like so:

INSTALLED_APPS = [
    ...
    "python_telegram_bot_django_persistence",  # For python-telegram-bot
    "aiogram_djpersistence",  # For aiogram
]

☢ Migrate your database

python manage migrate

🌟 Awesome! Now use it in your bot!

python-telegram-bot

updater = Updater(bot=bot, use_context=True, persistence=DjangoPersistence())

aiogram

dp = Dispatcher(storage=DjangoStorage())

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Alexander Shishenko
Alexander Shishenko

💻 📖
Raman Hutkovich
Raman Hutkovich

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

Project details


Download files

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

Source Distribution

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page