DjVite
Integrates Vite resources into a Django web site.
Web requests are first served through vite dev server, then either proxified to django dev server or served directly.
This simulates a nginx proxy and wsgi server.
How to use
Django side
- Add
djviteto yourINSTALLED_APPSdjango config and define your static directories.
# settings.py
INSTALLED_APPS = [
...
'djvite',
]
STATIC_URL = "static/"
STATIC_ROOT = BASE_DIR / 'static'
STATICFILES_DIRS = ['dist']
- Load the
djviteplugin into your templates. - Inject any script or link from vite into your template:
{% vite hotreload %}enables vite hot module reload in dev mode{% vite '/src/main.js' %}for module{% vite '/src/style.css' %}for asset- Add any attributes to the
vitetag and it will be added to the final tags. - Specifiy multiple sources within one
vitetag, separate them with spaces.
<!-- myapp/templates/index.html -->
<html>{% load djvite %}
<heead>
<title>My title</title>
{% vite hotreload '/src/main.js' %}
</head>
...
</html>
Notes:
You can use the get_nginx_config command to generate a working nginx static configuration.
Vite side
- Add
DjVitePluginto yourvite.config.jsfile:
// vite.config.js
import { defineConfig } from 'vite'
import DjVitePlugin from 'djvite'
export default defineConfig({
plugins: [
DjVitePlugin({verbose: true}),
],
})
Configuration
In django settings:
DJVITEdict, with the following keys:DEV_MODE(boolean, defaultTrue)
WhenFalse, resources are resolved using thevite-manifest.jsonfile that list bundle files. This file is generated usingvite build.MODULE_EXTS(extension list, default ot['.js'])
Use this to provide other extensions to be served as module, for instance['.js', '.ts', '.jsx', '.tsx']in Typescript React application.VITE_MANIFEST_PATH(Path | str, default tovite.manifest.json)
Location to search for the Vite manifest. Used whenDEV_MODEisFalse.
In vite config plugin:
optionsobject forDjVitePlugin.verbosedefault tofalse.djangoPortdefault toDJANGO_PORTenvironment variable or8000if not defined.djangoTemplatesGlobdefault to the globbing pattern**/templates.manifestPathdefault tovite.manifest.json.
Metadata
Release files for djvite 1.5.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 | Provenance | |
|---|---|---|---|---|
| djvite-1.5.0.tar.gz | 11.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| djvite-1.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.5 kB
Release files / djvite-1.5.0.tar.gz
| Download URL | djvite-1.5.0.tar.gz |
|---|---|
| Size | 11.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d169d5d311748e467669cff402183974e26cd6b199f30802898d13d2d6d6c459
|
|
BLAKE2b-256 checksum How to use checksums |
65f1c7b0a24de32e472874ac9931f38ce5bc6aa7f611833c930f857c7be4261f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.23.0","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / djvite-1.5.0-py3-none-any.whl
| Download URL | djvite-1.5.0-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c9db5b4fe9958acf85ae9a54bf1e4821b07fec47cbfe5b7b815651199c348cb0
|
|
BLAKE2b-256 checksum How to use checksums |
d5d717c9eef7cf29dab42615f0f35420dd49edcdd4e9b606bfd7ea20bdfd2640
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.23.0","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for djvite 1.5.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.