django-inertia
Django server-side new adapter for Inertia.js.
Getting Started
Install the package
pip install django-inertia
Configure your project
-
Add the package
django_inertiato your project (if you want to use the template tag else it's not necessary). -
Add
InertiaMiddlewareto your project middlewares:
MIDDLEWARES = [
#...,
"django_inertia.middleware.InertiaMiddleware",
]
Creating responses
To create and inertia response you need to use Inertia.render() method:
from django_inertia import Inertia
def event_detail(request, id):
event = Event.objects.get(pk=id)
props = {
'event': {
'id':event.id,
'title': event.title,
'start_date': event.start_date,
'description': event.description
}
}
return Inertia.render(request, "Event/Show", props)
Loading data into your template
{% load inertia_tags %}
{% load static %}
<!DOCTYPE html>
<html class="h-full bg-gray-200">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<script src="{% static 'dist/app.js' %}" defer></script>
<link href="{% static 'dist/app.css' %}" rel="stylesheet" />
</head>
<body>
{% inertia %}
</body>
</html>
Full documentation
TODO
Inertia.share()
Inertia.render()
Inertia.version()
Inertia.get_version()
Inertia.flush_shared()
Inertia.lazy()
Inertia.static()
Credits
Thanks to Andres Vargas for the inspiration on this package. Here is the link to its legacy package which seems not be actively maintained anymore: inertia-django
Contributing
TODO
Maintainers
License
django-inertia is open-sourced software licensed under the MIT license.
Release files for django-inertia 1.3.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 | |
|---|---|---|---|
| django-inertia-1.3.0.tar.gz | 15.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_inertia-1.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.2 kB
Release files / django-inertia-1.3.0.tar.gz
| Download URL | django-inertia-1.3.0.tar.gz |
|---|---|
| Size | 15.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
101850375f821401597b6285707815226f95423abd6f13a60009d16b9143c15d
|
|
BLAKE2b-256 checksum How to use checksums |
d9950a04a26cb09a42e74ab970da11ea32bdbbf5189918d6a9e166488f03e40b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.10.4
|
Release files / django_inertia-1.3.0-py3-none-any.whl
| Download URL | django_inertia-1.3.0-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f881e647db359bd188a4a5446adb202b671b8b7363f68e4a258d0cece5b8efbb
|
|
BLAKE2b-256 checksum How to use checksums |
da5c5581f92e2ada305cc4ca52bbf5fef926ea6b651ba6225161292340b46487
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.10.4
|