Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stefanfoulis/django-sendsms
A simple API to send SMS messages. It is modeled after the django email api.
https://github.com/stefanfoulis/django-sendsms
django python sms
Last synced: about 10 hours ago
JSON representation
A simple API to send SMS messages. It is modeled after the django email api.
- Host: GitHub
- URL: https://github.com/stefanfoulis/django-sendsms
- Owner: stefanfoulis
- License: mit
- Created: 2011-08-10T06:40:48.000Z (over 13 years ago)
- Default Branch: main
- Last Pushed: 2024-01-28T06:18:00.000Z (almost 1 year ago)
- Last Synced: 2025-01-20T04:57:54.760Z (7 days ago)
- Topics: django, python, sms
- Language: Python
- Homepage:
- Size: 93.8 KB
- Stars: 259
- Watchers: 15
- Forks: 99
- Open Issues: 11
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.rst
- License: LICENSE
- Authors: AUTHORS.rst
Awesome Lists containing this project
README
==============
django-sendsms
==============.. image:: https://coveralls.io/repos/github/stefanfoulis/django-sendsms/badge.svg?branch=master
:target: https://coveralls.io/github/stefanfoulis/django-sendsms?branch=master.. image:: https://github.com/stefanfoulis/django-sendsms/workflows/Django%20Send%20SMS%20Build/badge.svg?branch=master
:target: https://github.com/stefanfoulis/django-sendsms/actions?query=workflow%3A%22Django%20Send%20SMS%20Build%22.. image:: https://badge.fury.io/py/django-sendsms.svg
:target: https://badge.fury.io/py/django-sendsmsA simple api to send SMS messages with django. The api is structured the same way as Django's own email api.
Installation
============::
pip install django-sendsms
Configure the ``SENDSMS_BACKEND`` (defaults to ``'sendsms.backends.console.SmsBackend'``)::
SENDSMS_BACKEND = 'myapp.mysmsbackend.SmsBackend'
Basic usage
===========Sending SMSs is like sending emails::
from sendsms import api
api.send_sms(body='I can haz txt', from_phone='+41791111111', to=['+41791234567'])You can also make instances of ``SmsMessage``::
from sendsms.message import SmsMessage
message = SmsMessage(body='lolcats make me hungry', from_phone='+41791111111', to=['+41791234567'])
message.send()Custom backends
===============Creating custom ``SmsBackend`` s::
from sendsms.backends.base import BaseSmsBackend
import some.sms.delivery.apiclass AwesomeSmsBackend(BaseSmsBackend):
def send_messages(self, messages):
for message in messages:
for to in message.to:
try:
some.sms.delivery.api.send(
message=message.body,
from_phone=message.from_phone,
to_phone=to,
flashing=message.flash
)
except:
if not self.fail_silently:
raiseThen all you need to do is reference your backend in the ``SENDSMS_BACKEND`` setting.
Running tests
=============::
python setup.py test
Or better, install and run "tox".
Contributing
============Pull requests are very welcome. Please make sure code is formatted using black and isort.