Skip to main content

django-mqtt

MQTT tools for Django project

PyPI Version PyPI Status PyPI License Published on Django Packages

Installation

# In your settings.py
# Update INSTALLED APPS
INSTALLED_APPS = [
    "django.contrib.auth",
    "django.contrib.sites",
    "django.contrib.contenttypes",
    "django.contrib.sessions",
    "...",
    "dmqtt", # << Add this to your apps
]

# Configure connection settings
MQTT_HOST = "localhost"
MQTT_PORT = 1883
MQTT_PASS = "testing"
MQTT_USER = "testing"

# Optional TLS settings
# https://eclipse.dev/paho/files/paho.mqtt.python/html/client.html#paho.mqtt.client.Client.tls_set
MQTT_TLS = {}

Usage

# Launch client that will listen to mqtt messages
python manage.py mqtt

# or send a test message to your broker
echo 'test-message' | python.manage mqtt my-topic

Configure senders to listen to mqtt signals

from dmqtt.signals import connect, regex, topic
from django.dispatch import receiver


@receiver(connect)
def on_connect(sender, **kwargs):
    sender.subscribe("#")


@topic("some/mqtt/topic")
def simple_topic(sender, topic, data, **kwargs):
    print(topic)
    print(data)


@regex("^some/(?P<username>[^/]+)/(?P<device>[^/]+)$")
def regex_topic(match, data, **kwargs):
    device = match.groupdict()
    print(device["username"], device["device"])
    print(data)

Authentication

mosquitto-go-auth

Used with https://github.com/iegomez/mosquitto-go-auth

# From example project urls
from django.contrib import admin
from django.urls import include, path

urlpatterns = [
    path("mosquitto/", include("dmqtt.mosquitto")),
    path("account/", include(("django.contrib.auth.urls", "auth"), namespace="auth")),
    path("admin/", admin.site.urls),
]
# mosquitto configuration
# https://github.com/iegomez/mosquitto-go-auth#http
auth_plugin /mosquitto/go-auth.so
auth_opt_backends http
auth_opt_check_prefix false

auth_opt_http_host example.com
auth_opt_http_getuser_uri /mosquitto/getuser
auth_opt_http_aclcheck_uri /mosquitto/aclcheck

# If using https
auth_opt_http_port 443
auth_opt_http_with_tls true

Metadata

Release files for django-mqtt 0.8.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-mqtt 0.8.1
File Size Uploaded Provenance Actions
django_mqtt-0.8.1.tar.gz 7.6 kB Without provenance Details for django_mqtt-0.8.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-mqtt 0.8.1
File Interpreter ABI Platform Actions
django_mqtt-0.8.1-py3-none-any.whl Python 3 none any Details for django_mqtt-0.8.1-py3-none-any.whl

Total release size: 17.8 kB

Release files / django_mqtt-0.8.1.tar.gz

Download URL django_mqtt-0.8.1.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
001b0040b28bdcbe5d445842ac8f1c7851cfe17e20110003440a02568b6f3ccf
BLAKE2b-256 checksum
How to use checksums
9e3a6a70ed93f936354118ee893e813bfe5be6a77dadb280191ad1d8066ce288
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / django_mqtt-0.8.1-py3-none-any.whl

Download URL django_mqtt-0.8.1-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
04218a50f19cbcb49b4558914bf57e945e8c1abb5294c467ea97c48774bfb2d4
BLAKE2b-256 checksum
How to use checksums
e47e2a165bc53ad840b98dc520d7d3ffd60dc79d82313f991a0e0a97d0bad4c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for django-mqtt 0.8.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page