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
- Getting started — the consuming-app shape, Django settings, building with Briefcase.
- Native bridges — speech / wallet / Apple Intelligence / notifications + their
Info.plistkeys and Swift shims. - Platform support — the capability matrix + the fail-soft contract.
- Contributing · Releasing
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:
-
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 ismaturin+ a BeeWare cross-platform venv for iOS, andcibuildwheel --platform androidfor Android (which manages the NDK download itself). -
Repackaging non-mobile native deps —
msgpackships 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.sofiles, and emits apy3-none-ios_..._iphoneos.whl/…_android_21_arm64_v8a.whlis enough. -
Briefcase scaffold patches — at least on Android, the generated
pip-options.txtneeds an absolute path for--find-links wheelsand the themecolorPrimaryDarkinres/values/colors.xmlneeds to matchstatus_bar_color_argb(the activity theme paints the status bar before any runtimesetStatusBarColorcall lands). -
POST_NOTIFICATIONS permission on Android 13+ if using
djust_mobile_toga.notifications— declare it in your Briefcase[tool.briefcase.app.<name>.android]block aspermission."android.permission.POST_NOTIFICATIONS" = "...". Without it the system silently drops notifications. -
Settings module that respects
DJUST_MOBILE_DATA_DIR— your Djangosettings.pyreads this env var (set byBaseDjustAppat 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)
| File | Size | Uploaded | |
|---|---|---|---|
| djust_mobile_toga-0.6.0.tar.gz | 30.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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 logRelease 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