Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gamepad64/python-telegram-bot-django-persistence
Package to use Django ORM as persistence engine in Python Telegram Bot
https://github.com/gamepad64/python-telegram-bot-django-persistence
aiogram django django-orm python python-telegram-bot
Last synced: 3 months ago
JSON representation
Package to use Django ORM as persistence engine in Python Telegram Bot
- Host: GitHub
- URL: https://github.com/gamepad64/python-telegram-bot-django-persistence
- Owner: GamePad64
- License: mit
- Created: 2021-07-19T22:58:02.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-19T02:19:47.000Z (4 months ago)
- Last Synced: 2024-09-19T02:58:10.544Z (4 months ago)
- Topics: aiogram, django, django-orm, python, python-telegram-bot
- Language: Python
- Homepage: https://pypi.org/project/python-telegram-bot-django-persistence/
- Size: 183 KB
- Stars: 22
- Watchers: 2
- Forks: 5
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# python-telegram-bot-django-persistence
[![PyPI - Downloads](https://img.shields.io/pypi/dm/python-telegram-bot-django-persistence?style=flat-square)](https://pypi.org/project/python-telegram-bot-django-persistence/)
[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)Do you use [python-telegram-bot](https://github.com/python-telegram-bot/python-telegram-bot) or [aiogram](https://github.com/aiogram/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](https://python-poetry.org) (and if not, please, consider using it 😉):
```shell
# 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:
```shell
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:```python
INSTALLED_APPS = [
...
"python_telegram_bot_django_persistence", # For python-telegram-bot
"aiogram_djpersistence", # For aiogram
]
```### ☢ Migrate your database
```shell
python manage migrate
```### 🌟 Awesome! Now use it in your bot!
#### python-telegram-bot
```python
updater = Updater(bot=bot, use_context=True, persistence=DjangoPersistence())
```
#### aiogram
```python
dp = Dispatcher(storage=DjangoStorage())
```## Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Alexander Shishenko
💻 📖
Raman Hutkovich
💻
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!