Skip to main content

django-inertia

GitHub Workflow Status (branch) Python Version PyPI License Code style: black

Django server-side new adapter for Inertia.js.

Getting Started

Install the package

pip install django-inertia

Configure your project

  1. Add the package django_inertia to your project (if you want to use the template tag else it's not necessary).

  2. Add InertiaMiddleware to 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)

Source distribution for django-inertia 1.3.0
File Size Uploaded
django-inertia-1.3.0.tar.gz 15.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-inertia 1.3.0
File Interpreter ABI Platform
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

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page