Skip to main content

djust-mobile-toga

Embed djust as an on-device loopback server inside a Toga + Briefcase mobile app. Extracted from a working reference app that runs the same Django + djust codebase on iOS Simulator and Android emulator with no remote backend.

The core three pieces:

Module What it does
djust_mobile_toga.shims Cross-platform compatibility shims (must run BEFORE importing uvicorn/Django).
djust_mobile_toga.serve Loopback-bound uvicorn helper that bypasses uvicorn.supervisors (iOS Python lacks _multiprocessing).
djust_mobile_toga.app BaseDjustApp(toga.App) — handles writable data dir, background-thread Django prep, uvicorn boot, WebView.

…plus optional, fail-soft native bridges — bridge (JS↔Python), passkit (Apple Wallet), voice (on-device STT/TTS), apple_intelligence (Foundation Models), notifications. See docs/native-bridges.md.

Status

Beta. Typed (py.typed), CI-gated (ruff + mypy + pytest on py3.11–3.13), and tested — the core (serve/shims/apps/templatetags/bridge) is at ~100% off-device coverage; the iOS/Android native bodies are hand-verified on a device (see docs/platform-support.md). The public API is stabilizing but may still evolve before a 1.0; pin a version.

Documentation

Quick start

# myapp/__main__.py
from djust_mobile_toga.app import BaseDjustApp


class MyApp(BaseDjustApp):
    asgi_app_path = "myapp.asgi:application"
    django_settings_module = "myapp.settings"
    status_bar_color_argb = 0xFF14457E  # opaque blue; remove for system default

    def on_app_ready(self):
        # Optional post-launch hook (notifications, analytics, etc.).
        pass


def main():
    return MyApp(
        formal_name="My App",
        app_id="org.example.myapp",
        app_name="myapp",
    )


if __name__ == "__main__":
    main().main_loop()

Then in your Toga app entry point (__main__.py for Briefcase), make sure the shims install BEFORE anything else imports uvicorn/Django:

from djust_mobile_toga import shims
shims.install()                   # CALL FIRST

from myapp.app import main
main().main_loop()

What's still on you (the consumer)

This package handles the runtime glue. The consumer is responsible for:

  1. Cross-compiling djust for iOS (aarch64-apple-ios, aarch64-apple-ios-sim) and/or Android (aarch64-linux-android, x86_64-linux-android). djust itself doesn't currently publish mobile wheels; the reference recipe is maturin + a BeeWare cross-platform venv for iOS, and cibuildwheel --platform android for Android (which manages the NDK download itself).

  2. Repackaging non-mobile native deps — msgpack ships a pure-Python fallback that needs to be re-tagged with iOS/Android platform tags so pip will install it under --platform. A small script that walks an installed package's __init__.py, strips compiled .so files, and emits a py3-none-ios_..._iphoneos.whl / …_android_21_arm64_v8a.whl is enough.

  3. Briefcase scaffold patches — at least on Android, the generated pip-options.txt needs an absolute path for --find-links wheels and the theme colorPrimaryDark in res/values/colors.xml needs to match status_bar_color_argb (the activity theme paints the status bar before any runtime setStatusBarColor call lands).

  4. POST_NOTIFICATIONS permission on Android 13+ if using djust_mobile_toga.notifications — declare it in your Briefcase [tool.briefcase.app.<name>.android] block as permission."android.permission.POST_NOTIFICATIONS" = "...". Without it the system silently drops notifications.

  5. Settings module that respects DJUST_MOBILE_DATA_DIR — your Django settings.py reads this env var (set by BaseDjustApp at startup) to place SQLite + collected static files somewhere writable.

License

MIT.

Metadata

Release files for djust-mobile-toga 0.6.0

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

Source distribution (sdist)

Source distribution for djust-mobile-toga 0.6.0
File Size Uploaded
djust_mobile_toga-0.6.0.tar.gz 30.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for djust-mobile-toga 0.6.0
File Interpreter ABI Platform
djust_mobile_toga-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 67.7 kB

Release files / djust_mobile_toga-0.6.0.tar.gz

Download URL djust_mobile_toga-0.6.0.tar.gz
Size 30.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9ecfbf93f9a59009ac85274a7b83200bb0ac09fcbe226b2d2dacce9ab2ca5c4f
BLAKE2b-256 checksum
How to use checksums
673c8f3f6b61fa0eb30d9ae3a49d09dc61522cd96b325e3920350bd28ca1bffd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 30, 2026.

Transparency log

Release files / djust_mobile_toga-0.6.0-py3-none-any.whl

Download URL djust_mobile_toga-0.6.0-py3-none-any.whl
Size 37.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
685f37630f91c62ca809ccc8c900bbfa014a0889844fb831ab6d3be42c3aa9c2
BLAKE2b-256 checksum
How to use checksums
4b19da73f855c2283eef5a9d590ee723efb917a0b7eeb5076c63154fed3cc5ad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 30, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 release files

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