A Django adapter for the RouteLit framework, enabling seamless integration of RouteLit's reactive UI components with Django web applications
Project description
RouteLit Django Adapter
A Django adapter for the RouteLit framework, enabling seamless integration of RouteLit's reactive UI components with Django web applications.
✨ Features
- Standard HTTP Support: Full page loads and JSON interactions.
- HTTP Streaming: Progressive UI updates using
StreamingHttpResponse. - Django Session Integration: Persistent state management using Django's session backend.
- Static Asset Serving: Automated configuration for serving RouteLit client assets.
🚀 Installation
pip install routelit routelit-django
📖 Usage
1. Configure RouteLit
In your views.py:
from routelit import RouteLit, RouteLitBuilder
from routelit_django import RouteLitDjangoAdapter, DjangoSessionStorage
# Initialize RouteLit with DjangoSessionStorage
rl = RouteLit(session_storage=DjangoSessionStorage())
adapter = RouteLitDjangoAdapter(rl)
def my_view(ui: RouteLitBuilder):
ui.title("Hello RouteLit!")
if ui.button("Click me"):
ui.text("Clicked!")
def index(request):
return adapter.response(my_view, request)
def stream(request):
return adapter.stream_response(my_view, request)
2. Configure URLs
In your urls.py:
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
path('stream/', views.stream, name='stream'),
]
# Register static assets
views.adapter.configure(urlpatterns)
3. Add to Installed Apps
In your settings.py:
INSTALLED_APPS = [
...
'routelit_django',
]
🏗️ Architecture
The Django adapter translates Django's HttpRequest into RouteLitRequest and handles the response generation using Django's HttpResponse, JsonResponse, and StreamingHttpResponse.
By using DjangoSessionStorage, the application state is stored directly in the user's Django session, making it compatible with any session backend (database, cache, etc.).
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 routelit_django-0.1.0.tar.gz.
File metadata
- Download URL: routelit_django-0.1.0.tar.gz
- Upload date:
- Size: 111.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7181532f686e8ceeb3278c03b33a67d30a9034bbca3daa92f95e152694b4c3cf
|
|
| MD5 |
227497cfc6b95a2d6ffa98019566eb44
|
|
| BLAKE2b-256 |
b0c5deb3b67534d5a9b87a764ee04dc2cecc68f7df814da48fbcbe3d06c9aa12
|
File details
Details for the file routelit_django-0.1.0-py3-none-any.whl.
File metadata
- Download URL: routelit_django-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f33477caa3a14d71aea59e0c50ae2ee7fbdafe6f9f16d87384d207136d7629ae
|
|
| MD5 |
d88def0c1dd38ce6c2e0593b5981f528
|
|
| BLAKE2b-256 |
9116610f6f8abd73df36862dd350ef64eebbe8c4c1adef46a1eff3e5cabed4bb
|