Coder Social home page Coder Social logo

django-sendsms's Introduction

django-sendsms

https://coveralls.io/repos/github/stefanfoulis/django-sendsms/badge.svg?branch=master https://travis-ci.org/stefanfoulis/django-sendsms.svg?branch=master

A 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.api

class 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:
                        raise

Then 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.

django-sendsms's People

Contributors

stefanfoulis avatar pawl-bb avatar psychok7 avatar pakal avatar denizdogan avatar iraycd avatar endormi avatar ataylor32 avatar superalex avatar kelvinwong-ca avatar mixxorz avatar reidransom avatar xiscosc avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.