A Django app for tracking and sending communications like Emails and WhatsApp messages.
Project description
django-communications
Overview
django-communications is a Django package designed to provide a central platform for sending different types of communications such as emails, SMS, WhatsApp messages, push notifications, and more. Currently, it supports sending emails using an SMTP provider.
Installation
To install django-communications, use pip:
pip install django-communications
Configuration
Add communication to your INSTALLED_APPS in settings.py:
INSTALLED_APPS = [
...
'communication',
]
Settings
Define the allowed communication types and configuration settings in settings.py:
from communication.constants.communication_types import CommunicationTypes
from communication.constants.providers import EmailProviders
ALLOWED_COMMUNICATION_TYPES = [CommunicationTypes.EMAIL]
COMMUNICATION_CONFIG = {
CommunicationTypes.EMAIL: {
'provider': EmailProviders.SMTP,
'smtp_host': 'smtp.gmail.com',
'smtp_port': '587',
'smtp_user': '',
'smtp_password': '',
'smtp_use_tls': True
}
}
Creating a Communication Event
Before sending communications, you need to create a Communication Event. This can be done through the Django Admin panel:
- Navigate to Communication Events in the Django Admin.
- Click Add Communication Event.
- Define a Code for the event.
- Select the allowed Communication Types.
- Ignore the fields Default Value and Can User Change Preference (reserved for future use).
- Save the event.
Once created, save the event's code in your constants for future use.
Sending a Communication
To send a communication, create a data_dict with the necessary details:
data_dict = {
'emails': ['example@example.com'],
'email_data': {
'subject': "This is a Subject",
'content': "This is content", # Content can be plain text or HTML
'attachments': [] # List of file paths if needed
}
}
Then, initiate the communication using:
from communication.communication import Communication
Communication().initiate_communication("{communication_event_code}", data_dict)
Background Processing
You can also send communications in the background using Celery or threads to improve performance:
from threading import Thread
Thread(target=Communication().initiate_communication, args=("{communication_event_code}", data_dict)).start()
Viewing Logs
All sent communications can be viewed in the Django Admin under Communication Requests, allowing tracking and debugging.
Future Enhancements
- Support for additional communication channels (SMS, WhatsApp, Push Notifications, etc.).
- User preference management for different communication types.
Contributing
If you'd like to contribute to django-communications, feel free to submit a pull request or report issues on the GitHub repository.
License
django-communications is open-source and available under the MIT License.
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_communications-0.1.0.tar.gz.
File metadata
- Download URL: django_communications-0.1.0.tar.gz
- Upload date:
- Size: 17.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d5ad147b71f58a0f7a1e096eb53c8d2a2acd953981d145a0cf37aceeea00731
|
|
| MD5 |
6965f0b1666a068727aa2eb45d87aaf0
|
|
| BLAKE2b-256 |
5fadc240052705f9e802885013656b1af0d090fda9a92f666654b6a91167036e
|
File details
Details for the file django_communications-0.1.0-py3-none-any.whl.
File metadata
- Download URL: django_communications-0.1.0-py3-none-any.whl
- Upload date:
- Size: 22.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4e29812740fd3d7927ca715fe6a1bcbfbef1ffbfe8279bb2ad4066a4111cfc1
|
|
| MD5 |
4992f1245713d110889a4b8aac855bcd
|
|
| BLAKE2b-256 |
6331415197c90f21d77d477be6a5b7766b590819d1d58666f14c83aafa41e995
|