A django module that allows to send short messages via the Anexia SMS gateway
Project description
Django Anexia SMS Gateway
A django module to send short messages via the Anexia SMS gateway (ASGW). It requires an active Anexia Engine subscription and a "ready to use" configured "sender" within your web service.
Installation
Install using pip:
pip install django-anexia-sms-gateway
In the project's settings.py add the access token configuration:
# Anexia SMS Gateway settings (ASGW)
ASGW_ACTIVE = True
ASGW_API_TOKEN = "your-asgw-api-token"
Usage
Call the send_sms
method wherever you want to trigger a short message:
from django_anexia_sms_gateway.sms import send_sms
send_sms(message="SMS content", destination="+43123456789")
Translation (message)
If you provide a translatable message string be sure to use ugettext
("gettext_lazy" would not be triggered on time):
from django.utils.translation import ugettext
from django_anexia_sms_gateway.sms import send_sms
send_sms(message=ugettext("Translatable SMS content"), destination="+43123456789")
Recipient phone number (destination)
The recipient's phone number (=destination
) must consist of prefix +
followed by 1 to 14 digits. Otherwise the ASGW API will return an error.
Phone number on model
In case you store the phone number on a model (e.g. User
), we recommend direct validation via RegexValidator
, e.g.:
from django.core.validators import RegexValidator
from django.db.models import CharField
from django.utils.translation import gettext_lazy as _
phone = CharField(
_("phone number"),
max_length=15,
blank=True,
help_text=_("Prefix '+' followed by 1-14 digits, e.g. '+436641234'"),
validators=[
RegexValidator(
r"^\+\d{1,14}$",
_("Phone number must be entered in the format: '+123456789'. Prefix '+' with 1 to 14 digits allowed."),
)
],
)
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
Hashes for django-anexia-sms-gateway-1.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e4471bb1091eb23e7595cd8126c997d4a8eb1441101583bcb2bf082207c6205 |
|
MD5 | 912367bdda62bf4ce6b927fa063cd3d0 |
|
BLAKE2b-256 | 73f32edfc75165398be7749228b05147f22776f3657377cd16a30d15cc5b8c7c |
Hashes for django_anexia_sms_gateway-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41d574f9f0d62e35112c5717d9f97032fed04c1627525d261f66c07712021284 |
|
MD5 | 6fbf2146b8f747e61b660898022d4e2a |
|
BLAKE2b-256 | 1dd5787da141721ba1e557059aa0ad986545b95067235083c39e469bbe3892b7 |