django-admin-json-highlight
A simple Django Admin mixin to render and syntax-highlight JSON / JSONField values using highlight.js.
Installation
pip install django-admin-json-highlight
Add to INSTALLED_APPS:
INSTALLED_APPS = [
# ...
"django_admin_json_highlight",
]
Usage
Mix JsonHighlightMixin into your ModelAdmin and use render_json_field to
produce HTML for any JSON-serializable attribute on the object.
from django.contrib import admin
from django_admin_json_highlight import JsonHighlightMixin
from .models import Event
@admin.register(Event)
class EventAdmin(JsonHighlightMixin, admin.ModelAdmin):
readonly_fields = ("payload_pretty",)
def payload_pretty(self, obj):
return self.render_json_field(obj, "payload")
payload_pretty.short_description = "Payload"
Configuration
The mixin loads highlight.js from cdnjs by default. Override either URL in
settings.py to use a different version, theme, or self-hosted asset:
HIGHLIGHT_JS_JS_URL = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/highlight.min.js"
HIGHLIGHT_JS_CSS_URL = "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/styles/github-dark.min.css"
Relative paths are resolved through Django's static tag, so you can also point
these at files served from your own STATICFILES_DIRS.
Requirements
- Python 3.10+
- Django 4.2+
Development
Install dev dependencies:
uv sync --dev
Run the test suite against the active interpreter:
uv run pytest
Matrix testing with nox
noxfile.py defines a Django × Python matrix matching CI. Nox provisions
interpreters via uv, so you do not need to install each Python version
manually.
List sessions:
uv run nox --list
Run the full matrix:
uv run nox
Run a single combination:
uv run nox -s "tests(python='3.13', django='6.0')"
Pass extra arguments through to pytest with --:
uv run nox -s "tests(python='3.13', django='6.0')" -- -k test_media -x
License
MIT
Metadata
Release files for django-admin-json-highlight 0.1.1
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 | Actions |
|---|---|---|---|---|
| django_admin_json_highlight-0.1.1.tar.gz | 4.1 kB | Without provenance | Details for django_admin_json_highlight-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_admin_json_highlight-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for django_admin_json_highlight-0.1.1-py3-none-any.whl |
Total release size: 11.1 kB
Release files / django_admin_json_highlight-0.1.1.tar.gz
| Download URL | django_admin_json_highlight-0.1.1.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ee9742870ff3d26dcf6881005a61249afe4457cded111a8d4b5973c535bbce22
|
|
BLAKE2b-256 checksum How to use checksums |
4ec4d57788dc2a5474403e381acda516e6fc846d50eda571fc9e58ef06844a66
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.9 {"installer":{"name":"uv","version":"0.11.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / django_admin_json_highlight-0.1.1-py3-none-any.whl
| Download URL | django_admin_json_highlight-0.1.1-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
673bee5fc6e327a71e3e0d82d64c79cb0648837fd387d8a4f77a01e3dbacce1c
|
|
BLAKE2b-256 checksum How to use checksums |
cab8249170b9617599ba4d1f8e182c8360b30f9413ad900e99eeecf55f571911
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.9 {"installer":{"name":"uv","version":"0.11.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for django-admin-json-highlight 0.1.1
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.