Embed djust as an on-device loopback server inside a Toga + Briefcase mobile app.
Project description
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.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file djust_mobile_toga-0.6.0.tar.gz.
File metadata
- Download URL: djust_mobile_toga-0.6.0.tar.gz
- Upload date:
- Size: 30.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ecfbf93f9a59009ac85274a7b83200bb0ac09fcbe226b2d2dacce9ab2ca5c4f
|
|
| MD5 |
82e9656107820c3e16aa66b0cf69d21f
|
|
| BLAKE2b-256 |
673c8f3f6b61fa0eb30d9ae3a49d09dc61522cd96b325e3920350bd28ca1bffd
|
Provenance
The following attestation bundles were made for djust_mobile_toga-0.6.0.tar.gz:
Publisher:
release.yml on djust-org/djust-mobile-toga
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
djust_mobile_toga-0.6.0.tar.gz -
Subject digest:
9ecfbf93f9a59009ac85274a7b83200bb0ac09fcbe226b2d2dacce9ab2ca5c4f - Sigstore transparency entry: 2028164935
- Sigstore integration time:
-
Permalink:
djust-org/djust-mobile-toga@66e38430e1f9d61b36bee65fe1a1fec93bdb5356 -
Branch / Tag:
refs/tags/v0.6.0 - Owner: https://github.com/djust-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@66e38430e1f9d61b36bee65fe1a1fec93bdb5356 -
Trigger Event:
push
-
Statement type:
File details
Details for the file djust_mobile_toga-0.6.0-py3-none-any.whl.
File metadata
- Download URL: djust_mobile_toga-0.6.0-py3-none-any.whl
- Upload date:
- Size: 37.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
685f37630f91c62ca809ccc8c900bbfa014a0889844fb831ab6d3be42c3aa9c2
|
|
| MD5 |
a2dc5ad53dd34a622578f0085b7e1523
|
|
| BLAKE2b-256 |
4b19da73f855c2283eef5a9d590ee723efb917a0b7eeb5076c63154fed3cc5ad
|
Provenance
The following attestation bundles were made for djust_mobile_toga-0.6.0-py3-none-any.whl:
Publisher:
release.yml on djust-org/djust-mobile-toga
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
djust_mobile_toga-0.6.0-py3-none-any.whl -
Subject digest:
685f37630f91c62ca809ccc8c900bbfa014a0889844fb831ab6d3be42c3aa9c2 - Sigstore transparency entry: 2028165157
- Sigstore integration time:
-
Permalink:
djust-org/djust-mobile-toga@66e38430e1f9d61b36bee65fe1a1fec93bdb5356 -
Branch / Tag:
refs/tags/v0.6.0 - Owner: https://github.com/djust-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@66e38430e1f9d61b36bee65fe1a1fec93bdb5356 -
Trigger Event:
push
-
Statement type: