2
2
![ Python package] ( https://github.com/zodman/inertia-django/workflows/Python%20package/badge.svg )
3
3
[ ![ Coverage Status] ( https://coveralls.io/repos/github/zodman/inertia-django/badge.svg?branch=master )] ( https://coveralls.io/github/zodman/inertia-django?branch=master )
4
4
5
- Based on inertia-laravel.
5
+ ### TL;DR:
6
6
7
- Check https://github.com/zodman/django-inertia-demo for example how to use
7
+ ` inertia-django ` connetor gives you the ability to replace 'classic' templates with ** Vue / React / Svelte** components.
8
+ - SPA user experience with MPA style development flow.
9
+ - No need for clientside routing, just use ` urls.py ` .
10
+ - No need for API endpoints, just pass data directly to the props of the client-side component.
11
+
12
+ based on inertia-laravel.
13
+
14
+ #### demo project available in this repo: https://github.com/zodman/django-inertia-demo
15
+ #### more on inertia: https://inertiajs.com
8
16
9
17
10
18
## Usage
@@ -19,7 +27,12 @@ from inertia import render_inertia
19
27
20
28
def index (request ):
21
29
# for function views just use the render_inertia function
22
- return render_inertia(request, ' Index' , props = {' title' : ' My inertia-django page' }, template_name = ' index.html' )
30
+ return render_inertia(
31
+ request,
32
+ ' Index' ,
33
+ props = {' title' : ' My inertia-django page' },
34
+ template_name = ' index.html'
35
+ )
23
36
```
24
37
25
38
----
@@ -32,7 +45,7 @@ def index(request):
32
45
33
46
### Root Template
34
47
35
- ``` html=
48
+ ``` html+django
36
49
{# templates/base.html #}
37
50
{% load js_routes_tags %}<!DOCTYPE html>
38
51
<html class="h-full bg-gray-200">
@@ -54,7 +67,7 @@ def index(request):
54
67
55
68
### Creating responses
56
69
57
- ``` python=
70
+ ``` python
58
71
from inertia.views import render_inertia
59
72
60
73
def event_detail (request , id ):
@@ -70,21 +83,21 @@ def event_detail(request, id):
70
83
return render_inertia(request, " Event/Show" , props)
71
84
```
72
85
73
- We strong suggest to use [ marshmallow] ( https://marshmallow.readthedocs.io/en/latest/ )
74
- because it had serializer and validation and fully compatible with django.
86
+ We strongly recommend to use [ marshmallow] ( https://marshmallow.readthedocs.io/en/latest/ )
87
+ since it has a serializer, validation and fully compatible with django.
75
88
76
89
77
90
## Client-side setup
78
91
### Install dependencies
79
- ```
92
+ ``` bash
80
93
npm install @inertiajs/inertia @inertiajs/inertia-vue
81
94
# extra deps
82
95
npm install parcel-bundler
83
96
```
84
97
85
98
### Initialize app
86
99
87
- ``` javascript=
100
+ ``` javascript
88
101
import { InertiaApp } from ' @inertiajs/inertia-vue'
89
102
import Vue from ' vue'
90
103
Vue .use (InertiaApp);
@@ -132,5 +145,3 @@ For the part of the urls the same functionality as laravel or ziggy is
132
145
133
146
# TODO: explain how inertia/middleware.py works
134
147
135
- # more info https://inertiajs.com/
136
-
0 commit comments