Skip to main content

A lightweight Django app for sending SMS messages through the ClickSend REST API.

Project description

Django ClickSend SMS

A lightweight Django app for sending SMS messages through the ClickSend REST API. Supports single SMS, bulk SMS, Django settings integration, and a test management command.


Features

  • Send a single SMS
  • Send bulk SMS
  • Easy Django integration
  • Simple, high-level SMS client
  • Optional test command (send_test_sms)
  • Works with Django 3.2+

Installation

Install using pip:

pip install django-clicksend-sms

Or install from a local folder:

pip install /path/to/django-clicksend-sms/

Django Setup

Add the app to your INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    "clicksend_sms",
]

Add your ClickSend credentials:

CLICKSEND_USERNAME = "your_clicksend_username"
CLICKSEND_API_KEY = "your_api_key"

Usage

Sending a Single SMS

from clicksend_sms.client import ClickSendSMSClient

def send_otp(phone, otp):
    client = ClickSendSMSClient()
    return client.send_sms(
        to=phone,
        message=f"Your OTP is {otp}"
    )

Sending Bulk SMS

from clicksend_sms.client import ClickSendSMSClient

client = ClickSendSMSClient()

messages = [
    {"to": "+1111111111", "message": "Hello User 1"},
    {"to": "+1222222222", "message": "Hello User 2", "sender_id": "MyApp"},
]

response = client.send_bulk_sms(messages)

print(response)

Management Command: Send Test SMS

You can quickly test sending an SMS using the built-in Django command.

python manage.py send_test_sms <phone> "<message>"

Example:

python manage.py send_test_sms +11234567890 "Hello from Django!"

Package Structure

clicksend_sms/
    __init__.py
    apps.py
    client.py
    settings.py
    management/
        commands/
            send_test_sms.py

How It Works

ClickSendSMSClient

This class handles:

  • Loading credentials from Django settings
  • Formatting message payloads
  • Sending requests to ClickSend REST API
  • Supporting both single and bulk SMS

Error Handling

Common errors:

  • Missing credentials:
ValueError: ClickSend credentials are not configured.
  • Non-JSON API response:
{"error": "Invalid JSON response", "status_code": ###}

Development

Install in editable mode:

pip install -e .

Build package for PyPI:

python setup.py sdist bdist_wheel

Upload:

twine upload dist/*

License

This project is free and open-source.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_click_send_sms-1.0.2-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file django_click_send_sms-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_click_send_sms-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0790e0af1c9d4642de92f1208e75e2b9e50e2881f7c680aa9ced5b251a5311b5
MD5 4b16985536a8bf40339af1eecc01644d
BLAKE2b-256 aaf39eaf45b3ab833b8d22a2a55f348295724a283a366a8f1a87010970fa868a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page