Python 3 Django to Send SMS Messages to Phone Using Twilio REST API in Browser

I’m writing every article I think will help you in some way. in that respect Python 3 Django to Send SMS Messages to Phone Using Twilio REST API in Browser This article will be very useful for you.

Short Message Service (SMS) Text messages are ubiquitous for time-sensitive communication. They can be easily sent by integrating the Django web application with an application programming interface (API).

In this tutorial, we will create a live Jango project with SMS capability to send messages to multiple recipients.

Python 3 Django to Send SMS Messages to Phone Using Twilio REST API in Browser

Python 3 Django to Send SMS Messages to Phone Using Twilio REST API in Browser

Django SMS Toolkit

Django module to send and store SMS with Twilio.

It is useful to read this before implementing any project involving phone numbers.

Releases

To release a new version via github.com, follow the steps in this link.

To release a new version via git commands, follow this documentation.

You can see the releases here.

Versioning

You can refer here for semantics of versioning.

Installation

  1. pip install django-sms-toolkit.
  2. Add django_sms_toolkit to the INSTALLED_APPS in the settings file.
  3. Configure settings.
DJANGO_SMS_TOOLKIT_SETTINGS = {
    "SEND_SMS": True,  # True by default.
    "DEFAULT_FROM_NUMBER": "",
    "TWILIO": {
        "ACCOUNT_SID": "",
        "AUTH_TOKEN": "",
        "STATUS_CALLBACK_BASE_URL": "https://www.myapp.com",
        "TRIM_LONG_BODY": True,  # True by default. Makes sure character limit is not exceeded.
    }
}
  1. python manage.py migrate
  2. Include urls to be able to receive message status callbacks from Twilio.
urlpatterns = [
    ....,
    url(r'^', include('django_sms_toolkit.urls')),
]
  1. (Optional) Add TwilioMessageMixin to your auth user model.
from django_sms_toolkit.models import TwilioMessageMixin

class AuthUser(TwilioMessageMixin,...):
    ....
    
# Default from number provided in settings is used if from_number is not provided.
user.send_sms(body, from_number=None)
# OR
from django_sms_toolkit.tasks import send_sms
send_sms.delay(from_number, to_number, body, recipient_id=None)

Read Also: Python 3 Django FFMPEG Web Video Converter Using django-webvideo Library in Browser

Final Thoughts

Python 3 Django to Send SMS Messages to Phone Using Twilio REST API in Browser Thank you for reading this useful article. Also, let us know if you have any doubts about this article. We are committed to helping you.

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Deekshi. Here, I post about programming to help developers.

Share on:

Leave a Comment