lamby / django-slack

Slack integration for Django, using the templating engine to generate messages
https://django-slack.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
241 stars 57 forks source link

slack_message fails silently #115

Open lexer21 opened 1 year ago

lexer21 commented 1 year ago

Hello im trying to send a test message on my local machine to my slack channel but it fails silently. I'm trying to run the following function send_msg in django shell but it fails silently. I have gotten a slack bot token setup, i have invited my bot to my #general channel. django_slack was added to INSTALLED_APPS.

I'm using:

from django_slack import slack_message

def send_msg():
    slack_message('test/message.slack', {
        'foo': "test"
    })

Here is imy message.slack template.

{% extends django_slack %}

{% block text %}
Message text here: {{ foo }}
{% endblock %}

My settings for TEMPLATES

TEMPLATES = [
    {
        "BACKEND": "django.template.backends.django.DjangoTemplates",
        "DIRS": [os.path.join(BASE_DIR, "templates")],
        "OPTIONS": {
            "context_processors": [
                "django.template.context_processors.debug",
                "django.template.context_processors.request",
                "django.contrib.auth.context_processors.auth",
                "django.contrib.messages.context_processors.messages",
            ],
            "loaders": [
                'django.template.loaders.filesystem.Loader',
                'django.template.loaders.app_directories.Loader'
            ]
        },
    },
]

Also i have noticed if I set SLACK_TOKEN to some invalid value, I dont get any error, it also fails silently.

serdarjan1995 commented 1 year ago

I have run into similar issue. In fact it was related with DEBUG=True, As described here https://django-slack.readthedocs.io/#slack-backend we need to manually set SLACK_BACKEND in settings.py

lamby commented 1 year ago

As in, it was incorrectly using the DisabledBackend...?