USX Django
solex-usx-django provides USX Django templates, block tags, Python rendering,
and the canonical component contracts. Python 3.12+ and Django 5.2 through 6.x are
supported. Node.js and a monorepo checkout are not required at runtime.
Installation
After the first PyPI release:
pip install solex-usx-django
Add "usx_django" to INSTALLED_APPS and enable APP_DIRS: True in the
DjangoTemplates backend. No custom template directories or
USX_COMPONENT_PATHS are needed. For an existing template library also named
components, explicitly map "components": "usx_django.templatetags.components"
in the backend's OPTIONS["libraries"].
{% load components %}
{% label htmlFor="email" required=True %}Email address{% endlabel %}
Tag names use underscores for hyphenated component names, for example
{% form_group %}...{% endform_group %}. Every component tag requires its
closing tag. Keyword arguments are props; props=my_dict forwards a dictionary,
with explicit keywords taking precedence. as variable captures the output.
from usx_django import get_contracts, render_component
html = render_component("label", {"htmlFor": "email", "label": "Email address"})
label_contract = get_contracts()["components"]["label"]
The Python renderer applies contract defaults and rejects unknown prop names;
it does not enforce required props or validate prop types. Block tags retain
their existing template behavior. Contract component references remain references,
not recursively expanded schemas. The complete manifest is also available via
importlib.resources.files("usx_django").joinpath("component-contracts.json").
Ordinary template variables are escaped. Props that intentionally accept HTML or JavaScript handlers must contain trusted content, not unsanitized user input.
Styles And Assets
This is a server-rendering package, not a frontend bundle. Supply the USWDS/USX
CSS, fonts, images, sprites, and required JavaScript separately through your
frontend build or static hosting. Configure Django's STATIC_URL or pass
staticBaseUrl to asset-aware components. Installing this package alone does
not style components or initialize interactive behaviors.
Building And Publishing
From the repository root, in an activated Python virtual environment:
pnpm install
python -m pip install build twine
pnpm generate:django
python -m build packages/usx-django
python -m twine check packages/usx-django/dist/*
The generator validates the canonical configs, copies the shared Python runtime
from apps/storybook-django/project/components, and bundles every
*.django.html, config.json, and Python helper from
packages/usx-react/src/components. Generated package files are ignored by Git;
edit those source locations and regenerate before every build. The source
distribution is self-contained and can rebuild a wheel without Node.js or
the original checkout.
Test the wheel in a separate environment before upload:
python -m venv /tmp/usx-wheel-test
/tmp/usx-wheel-test/bin/pip install packages/usx-django/dist/*.whl
/tmp/usx-wheel-test/bin/python -I packages/usx-django/tests/test_installed.py
Set a new version in pyproject.toml for each release and remove old artifacts
from the package's dist/ before rebuilding. Python releases are independent
of npm Changesets. With your own PyPI credentials or trusted publishing setup:
python -m twine upload --repository testpypi packages/usx-django/dist/*
python -m twine upload packages/usx-django/dist/*
Confirm ownership/availability of solex-usx-django on PyPI before the first
upload. Never commit registry credentials. Building does not publish anything.
Metadata
Release files for solex-usx-django 0.1.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 | |
|---|---|---|---|
| solex_usx_django-0.1.0.tar.gz | 116.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| solex_usx_django-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 289.0 kB
Release files / solex_usx_django-0.1.0.tar.gz
| Download URL | solex_usx_django-0.1.0.tar.gz |
|---|---|
| Size | 116.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b3bd6302580df563529be6aa15678e39f1e1e853d3597ecabd45f105a453f70d
|
|
BLAKE2b-256 checksum How to use checksums |
491b141e242b0c7b48ffc622f0caa98c267571af53ac148336087d95940c5055
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / solex_usx_django-0.1.0-py3-none-any.whl
| Download URL | solex_usx_django-0.1.0-py3-none-any.whl |
|---|---|
| Size | 172.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3f3cf3c3446beab189906889b6dffbd23342fcb65be9491ec568bb73873fa5c8
|
|
BLAKE2b-256 checksum How to use checksums |
67ff974f89285bb50eb7223b56aac3cbd4fe30df0d05f6a4558376296fd990b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|