Registry / web-framework / django-slack

django-slack

JSON →
library5.19.0pypypiunverified

django-slack provides easy-to-use integration between Django projects and the Slack group chat and IM tool. It simplifies sending messages and notifications to Slack channels. Currently at version 5.19.0, it is actively maintained with regular updates, typically released multiple times a year to follow Django versions or introduce new features and fixes.

pip install django-slack
INSTALL
IMPORT
SIG · DJANGO-SLACK
D
django-slack
web-frameworkpythonv5.19.0
Install
4.1s avg
Import
Disk
69MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v5.19.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 69.9MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 4.1s · import 0.000s · 70MB
69MB installed
● package 69MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

slack_message
from django_slack import slack_message
from django_slack import slack_message

This quickstart demonstrates how to send a simple Slack message. It includes a minimal Django settings configuration to make the snippet runnable outside of a full Django project (e.g., as a standalone script). In a real Django project, ensure 'slack' is in `INSTALLED_APPS` and `SLACK_WEBHOOK_URL` (or `SLACK_TOKEN`) is defined in your `settings.py`.

import os from django.conf import settings import django # Configure Django settings minimally for a standalone script # In a full Django project, these settings would be in your settings.py if not settings.configured: settings.configure( INSTALLED_APPS=['slack'], # Replace with your actual Slack Incoming Webhook URL # or SLACK_TOKEN if using the full API SLACK_WEBHOOK_URL=os.environ.get( 'SLACK_WEBHOOK_URL', 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX' # Placeholder URL ), # A secret key is required by Django for settings.configure SECRET_KEY='a-secret-key-for-demo-purposes-only', DEBUG=True, # Minimal database and timezone settings for django.setup() to work DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:',}}, USE_TZ=True, TIME_ZONE='UTC', ) django.setup() from slack import slack_message # Send a simple message to a specific Slack channel # Ensure the channel exists and your webhook/token has permissions slack_message( text='Hello from Django-Slack! This is a quickstart test message.', channel='#general', # Replace with your target channel name username='DjangoBot', icon_emoji=':rocket:' ) print("Attempted to send message to Slack. Check your configured channel.") # Note: Actual delivery depends on correct Slack configuration and network access.
Debug
Known issues
breakingThe `slack.signals.slack_message_pre_send` and `slack.signals.slack_message_post_send` signals were removed in version 5.0.0.
fix
Migrate to the new `slack.signals.message_sending` and `slack.signals.message_sent` signals, which provide similar functionality with a different signature. Review the official documentation for updated signal usage.
affects: >=5.0.0
breakingThe `SLACK_INCOMING_WEBHOOK_URL` setting was renamed to `SLACK_WEBHOOK_URL` for consistency in version 5.0.0.
fix
Update your `settings.py` to use `SLACK_WEBHOOK_URL`. The old setting might still work as a fallback but is considered deprecated.
affects: >=5.0.0
gotchaThe primary import path for modules changed from `django_slack` to `slack` in version 4.0.0.
fix
Ensure all imports use `from slack import ...` (e.g., `from slack import slack_message`) instead of `from django_slack import ...`.
affects: >=4.0.0
gotchaUnderstanding the difference between `SLACK_TOKEN` and `SLACK_WEBHOOK_URL` is crucial for correct setup.
fix
`SLACK_WEBHOOK_URL` is for incoming webhooks (simpler setup, limited features), while `SLACK_TOKEN` is for using the full Slack Web API (requires an app token, provides more control). Choose based on your integration needs and configure the respective setting in `settings.py`.
affects: All
Upgrade
Version history
5.19.0latest on PyPI · released Mar 2, 2023
Audit
Dependencies
requestsrequiredUsed for making HTTP requests to the Slack API and webhooks.
Agent activity
38 hits · last 30 days
node
32
OpenAI (training)
1
Resources
django-slack — pip install django-slack · libregistry