1

So, I have been working on utilizing this package: https://pypi.org/project/django-log-to-telegram/

I went through the exact steps the manual has: pip installing django log to telegram package,

Added the app in INSTALLED_APPS,

Added the telegram bot token after creating the telegram bot

LOG_TO_TELEGRAM_BOT_TOKEN = '1489551033:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

And adding LOGGING onto the settings:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        },
    },
    'handlers': {
        'telegram_log': {
            'level': 'ERROR',
            'filters': [],
            'class': 'django_log_to_telegram.log.AdminTelegramHandler',
            'bot_token': LOG_TO_TELEGRAM_BOT_TOKEN,
        },
            'mail_admins': {
            'level': 'ERROR',
            'class': 'django.utils.log.AdminEmailHandler'
        }
    },
    'loggers': {
        'django.request': {
            'handlers': ['telegram_log'],
            'level': 'ERROR',
            'propagate': True,
        },
    },
}

Then I ran 'python manage.py migrate' to create the django-log-to-telegram models. It's supposed to create the django-log-to-telegram table in the database. However, I do not see any new database.

W.H.N.A.
  • 327
  • 2
  • 7

1 Answers1

0

Try to add chat_id to django_log_to_telegram_botdata table in your databse

id | bot_token | chat_id

chat_id should be an integer

if you want the bot to send messages to the channel set chat_id as negative integer

Push_okkk
  • 9
  • 3