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.

Metadata

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 Provenance Actions
django-inertia-1.3.0.tar.gz 15.3 kB Without provenance Details for django-inertia-1.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-inertia 1.3.0
File Interpreter ABI Platform Actions
django_inertia-1.3.0-py3-none-any.whl Python 3 none any Details for django_inertia-1.3.0-py3-none-any.whl

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

Security for django-inertia 1.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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