A Django admin mixin to view any model record as formatted JSON
Project description
django-admin-json-view
A simple Django admin mixin that adds a "View as JSON" button to any model's change form. Click it to open a modal with the record's data as formatted JSON — ready to copy.
Installation
pip install django-admin-json-view
Add to INSTALLED_APPS:
INSTALLED_APPS = [
...
"admin_json_view",
]
Include the URLs in your urls.py:
from django.urls import path, include
urlpatterns = [
path("admin/", admin.site.urls),
path("admin-json-view/", include("admin_json_view.urls")),
]
Usage
Add JsonViewMixin to any ModelAdmin:
from admin_json_view.mixins import JsonViewMixin
from django.contrib import admin
from .models import Student
@admin.register(Student)
class StudentAdmin(JsonViewMixin, admin.ModelAdmin):
pass
That's it. A "{ } View as JSON" button will appear in the top-right of the change form.
Configuration
| Option | Default | Description |
|---|---|---|
json_depth |
0 |
How deep to serialize relations. 0 = direct fields only, 1 = one level of related objects |
json_exclude_fields |
[] |
List of field names to exclude from the output |
@admin.register(Student)
class StudentAdmin(JsonViewMixin, admin.ModelAdmin):
json_depth = 1
json_exclude_fields = ["password", "token"]
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_admin_json_view-0.1.0.tar.gz.
File metadata
- Download URL: django_admin_json_view-0.1.0.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0bf2d281f7414e19ef5d88dcaa5ae0c56768e4d284348f0b6edb65dee85ad1d
|
|
| MD5 |
13505e3da5a681f68c2191df802cce09
|
|
| BLAKE2b-256 |
0c2eec1488087140c9c68aba0c167da78f2cf75c018fefc8997e0175a31e3fa9
|
File details
Details for the file django_admin_json_view-0.1.0-py3-none-any.whl.
File metadata
- Download URL: django_admin_json_view-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d478904aa575b0f97e0c328e6c4c72cd1c1b186897508f488fde7f5f8c72d83
|
|
| MD5 |
f1dbbfb65c4904e3c54317494b1eeb98
|
|
| BLAKE2b-256 |
5fce08e3ab13a21c3a704523b901d5901625988a28a633971e9627cfa8ec94be
|