django-json-widget 2.1.0__tar.gz → 2.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django_json_widget-2.2.0/.github/workflows/javascript-tests.yml +18 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/.github/workflows/tests.yml +1 -1
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/.gitignore +4 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/CHANGELOG.rst +12 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/CONTRIBUTING.md +3 -3
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/PKG-INFO +301 -237
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/README.rst +57 -0
- django_json_widget-2.2.0/django_json_widget/__init__.py +1 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/django_json_widget/static/dist/jsoneditor.min.css +2 -2
- django_json_widget-2.2.0/django_json_widget/static/django_json_widget.js +38 -0
- django_json_widget-2.2.0/django_json_widget/templates/django_json_widget.html +7 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/django_json_widget/widgets.py +8 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/django_json_widget.egg-info/PKG-INFO +301 -237
- django_json_widget-2.2.0/django_json_widget.egg-info/SOURCES.txt +99 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/django_json_widget.egg-info/not-zip-safe +1 -1
- django_json_widget-2.2.0/example/characters/admin.py +20 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/example/characters/models.py +5 -0
- django_json_widget-2.2.0/example/example/reproduction_settings.py +3 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/example/example/settings.py +3 -7
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/example/manage.py +0 -0
- django_json_widget-2.2.0/example/wagtail_demo/.dockerignore +39 -0
- django_json_widget-2.2.0/example/wagtail_demo/DEMO.md +21 -0
- django_json_widget-2.2.0/example/wagtail_demo/Dockerfile +60 -0
- django_json_widget-2.2.0/example/wagtail_demo/home/apps.py +6 -0
- django_json_widget-2.2.0/example/wagtail_demo/home/migrations/0001_initial.py +31 -0
- django_json_widget-2.2.0/example/wagtail_demo/home/migrations/0002_create_homepage.py +66 -0
- django_json_widget-2.2.0/example/wagtail_demo/home/migrations/0003_homepage_settings_json_jsonitem.py +28 -0
- django_json_widget-2.2.0/example/wagtail_demo/home/migrations/__init__.py +0 -0
- django_json_widget-2.2.0/example/wagtail_demo/home/models.py +23 -0
- django_json_widget-2.2.0/example/wagtail_demo/home/static/css/welcome_page.css +184 -0
- django_json_widget-2.2.0/example/wagtail_demo/home/templates/home/home_page.html +21 -0
- django_json_widget-2.2.0/example/wagtail_demo/home/templates/home/welcome_page.html +52 -0
- django_json_widget-2.2.0/example/wagtail_demo/home/tests.py +42 -0
- django_json_widget-2.2.0/example/wagtail_demo/manage.py +22 -0
- django_json_widget-2.2.0/example/wagtail_demo/requirements.txt +2 -0
- django_json_widget-2.2.0/example/wagtail_demo/search/__init__.py +0 -0
- django_json_widget-2.2.0/example/wagtail_demo/search/templates/search/search.html +38 -0
- django_json_widget-2.2.0/example/wagtail_demo/search/views.py +46 -0
- django_json_widget-2.2.0/example/wagtail_demo/wagtail_demo/__init__.py +0 -0
- django_json_widget-2.2.0/example/wagtail_demo/wagtail_demo/settings/__init__.py +0 -0
- django_json_widget-2.2.0/example/wagtail_demo/wagtail_demo/settings/base.py +182 -0
- django_json_widget-2.2.0/example/wagtail_demo/wagtail_demo/settings/dev.py +18 -0
- django_json_widget-2.2.0/example/wagtail_demo/wagtail_demo/settings/production.py +14 -0
- django_json_widget-2.2.0/example/wagtail_demo/wagtail_demo/static/css/wagtail_demo.css +0 -0
- django_json_widget-2.2.0/example/wagtail_demo/wagtail_demo/static/js/wagtail_demo.js +0 -0
- django_json_widget-2.2.0/example/wagtail_demo/wagtail_demo/templates/404.html +11 -0
- django_json_widget-2.2.0/example/wagtail_demo/wagtail_demo/templates/500.html +13 -0
- django_json_widget-2.2.0/example/wagtail_demo/wagtail_demo/templates/base.html +46 -0
- django_json_widget-2.2.0/example/wagtail_demo/wagtail_demo/urls.py +35 -0
- django_json_widget-2.2.0/example/wagtail_demo/wagtail_demo/wsgi.py +16 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/requirements_dev.txt +8 -9
- django_json_widget-2.2.0/requirements_test.txt +2 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/setup.cfg +16 -16
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/setup.py +1 -6
- django_json_widget-2.2.0/tests/__init__.py +0 -0
- django_json_widget-2.2.0/tests/test_inline_editor.js +76 -0
- django_json_widget-2.2.0/tests/test_jsoneditor_access.py +47 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/tests/test_logic.py +14 -11
- django_json_widget-2.2.0/tests/test_wagtail.py +73 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/tests/test_widget_security.py +2 -2
- django_json_widget-2.2.0/tests/wagtail_settings.py +19 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/tox.ini +4 -9
- django_json_widget-2.1.0/django_json_widget/__init__.py +0 -1
- django_json_widget-2.1.0/django_json_widget/templates/django_json_widget.html +0 -29
- django_json_widget-2.1.0/django_json_widget.egg-info/SOURCES.txt +0 -62
- django_json_widget-2.1.0/example/characters/admin.py +0 -11
- django_json_widget-2.1.0/requirements_test.txt +0 -7
- django_json_widget-2.1.0/tests/test_jsoneditor_access.py +0 -60
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/.coveragerc +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/.editorconfig +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/.github/ISSUE_TEMPLATE.md +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/.travis.yml +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/AUTHORS.rst +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/LICENSE +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/MANIFEST.in +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/Makefile +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/django_json_widget/apps.py +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/django_json_widget/models.py +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/django_json_widget/static/css/django_json_widget.css +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/django_json_widget/static/dist/img/jsoneditor-icons.svg +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/django_json_widget/static/dist/jsoneditor.min.js +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/django_json_widget/urls.py +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/django_json_widget/views.py +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/django_json_widget.egg-info/dependency_links.txt +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/django_json_widget.egg-info/top_level.txt +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/example/README.md +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/example/characters/__init__.py +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/example/characters/apps.py +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/example/characters/migrations/0001_initial.py +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/example/characters/migrations/0002_alter_character_data_alter_character_other_data.py +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/example/characters/migrations/__init__.py +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/example/characters/tests.py +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/example/characters/views.py +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/example/example/__init__.py +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/example/example/urls.py +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/example/example/wsgi.py +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/example/requirements.txt +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/example/templates/django_json_widget/base.html +0 -0
- {django_json_widget-2.1.0/tests → django_json_widget-2.2.0/example/wagtail_demo/home}/__init__.py +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/imgs/jsonfield_0.png +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/imgs/jsonfield_1.png +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/manage.py +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/pyproject.toml +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/requirements.txt +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/tests/settings.py +0 -0
- {django_json_widget-2.1.0 → django_json_widget-2.2.0}/tests/templates/django/forms/widgets/attrs.html +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
name: JavaScript Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ master ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ master ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
inline-editor:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
- uses: actions/setup-node@v4
|
|
15
|
+
with:
|
|
16
|
+
node-version: '20'
|
|
17
|
+
- name: Test inline editor initialization
|
|
18
|
+
run: node --test tests/test_inline_editor.js
|
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
Changelog
|
|
3
3
|
=========
|
|
4
4
|
|
|
5
|
+
2.2.0 (2026-11-13)
|
|
6
|
+
------------------
|
|
7
|
+
|
|
8
|
+
* Added CSP guide.
|
|
9
|
+
* Implemented Wagtail support.
|
|
10
|
+
* Fixed inline editors.
|
|
11
|
+
|
|
12
|
+
2.1.1 (2025-12-12)
|
|
13
|
+
------------------
|
|
14
|
+
|
|
15
|
+
* Issue #108: respect Django admin color scheme setting for JSON editor.
|
|
16
|
+
|
|
5
17
|
2.1.0 (2025-10-24)
|
|
6
18
|
------------------
|
|
7
19
|
|
|
@@ -57,9 +57,9 @@ Ready to contribute? Here's how to set up `django-json-widget` for local develop
|
|
|
57
57
|
pip install -r requirements_test.txt
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
-
4. Create a branch for local development from the
|
|
60
|
+
4. Create a branch for local development from the master branch:
|
|
61
61
|
```bash
|
|
62
|
-
git checkout
|
|
62
|
+
git checkout master
|
|
63
63
|
git checkout -b name-of-your-branch
|
|
64
64
|
```
|
|
65
65
|
|
|
@@ -78,6 +78,6 @@ Ready to contribute? Here's how to set up `django-json-widget` for local develop
|
|
|
78
78
|
|
|
79
79
|
Before you submit a pull request, check that it meets these guidelines:
|
|
80
80
|
|
|
81
|
-
1. **The pull request must be submitted against the `
|
|
81
|
+
1. **The pull request must be submitted against the `master` branch.**
|
|
82
82
|
2. Please explain what you have done in the pull request.
|
|
83
83
|
3. Make sure you have had passed pre-commit hooks.
|
|
@@ -1,237 +1,301 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: django-json-widget
|
|
3
|
-
Version: 2.
|
|
4
|
-
Summary: Django json widget is an alternative widget that makes it easy to edit the jsonfield field of django.
|
|
5
|
-
Home-page: https://github.com/jmrivas86/django-json-widget
|
|
6
|
-
Author: José Manuel Rivas
|
|
7
|
-
Author-email: jmrivas86@gmail.com
|
|
8
|
-
License: MIT
|
|
9
|
-
Keywords: django-json-widget
|
|
10
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
-
Classifier: Framework :: Django
|
|
12
|
-
Classifier: Framework :: Django ::
|
|
13
|
-
Classifier: Framework :: Django ::
|
|
14
|
-
Classifier:
|
|
15
|
-
Classifier:
|
|
16
|
-
Classifier:
|
|
17
|
-
Classifier:
|
|
18
|
-
Classifier:
|
|
19
|
-
Classifier: Programming Language :: Python :: 3
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
Dynamic:
|
|
28
|
-
Dynamic:
|
|
29
|
-
Dynamic:
|
|
30
|
-
Dynamic:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
*
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: django-json-widget
|
|
3
|
+
Version: 2.2.0
|
|
4
|
+
Summary: Django json widget is an alternative widget that makes it easy to edit the jsonfield field of django.
|
|
5
|
+
Home-page: https://github.com/jmrivas86/django-json-widget
|
|
6
|
+
Author: José Manuel Rivas
|
|
7
|
+
Author-email: jmrivas86@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Keywords: django-json-widget
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Framework :: Django
|
|
12
|
+
Classifier: Framework :: Django :: 5.0
|
|
13
|
+
Classifier: Framework :: Django :: 5.2
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
16
|
+
Classifier: Natural Language :: English
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
License-File: AUTHORS.rst
|
|
22
|
+
Dynamic: author
|
|
23
|
+
Dynamic: author-email
|
|
24
|
+
Dynamic: classifier
|
|
25
|
+
Dynamic: description
|
|
26
|
+
Dynamic: home-page
|
|
27
|
+
Dynamic: keywords
|
|
28
|
+
Dynamic: license
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
Dynamic: summary
|
|
31
|
+
|
|
32
|
+
=============================
|
|
33
|
+
django-json-widget
|
|
34
|
+
=============================
|
|
35
|
+
|
|
36
|
+
.. image:: https://badge.fury.io/py/django-json-widget.svg
|
|
37
|
+
:target: https://badge.fury.io/py/django-json-widget
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
An alternative widget that makes it easy to edit the new Django's field JSONField (PostgreSQL specific model fields)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
Quickstart
|
|
44
|
+
----------
|
|
45
|
+
|
|
46
|
+
Install django-json-widget::
|
|
47
|
+
|
|
48
|
+
pip install django-json-widget
|
|
49
|
+
|
|
50
|
+
Add it to your `INSTALLED_APPS`:
|
|
51
|
+
|
|
52
|
+
.. code-block:: python
|
|
53
|
+
|
|
54
|
+
INSTALLED_APPS = (
|
|
55
|
+
...
|
|
56
|
+
'django_json_widget',
|
|
57
|
+
...
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
Add the widget in your admin.py:
|
|
61
|
+
|
|
62
|
+
.. code-block:: python
|
|
63
|
+
|
|
64
|
+
from django.contrib import admin
|
|
65
|
+
from django.db.models import JSONField
|
|
66
|
+
from django_json_widget.widgets import JSONEditorWidget
|
|
67
|
+
from .models import YourModel
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@admin.register(YourModel)
|
|
71
|
+
class YourModelAdmin(admin.ModelAdmin):
|
|
72
|
+
formfield_overrides = {
|
|
73
|
+
JSONField: {'widget': JSONEditorWidget},
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
You can also add the widget in your forms.py:
|
|
77
|
+
|
|
78
|
+
.. code-block:: python
|
|
79
|
+
|
|
80
|
+
from django import forms
|
|
81
|
+
from django_json_widget.widgets import JSONEditorWidget
|
|
82
|
+
from .models import YourModel
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class YourForm(forms.ModelForm):
|
|
86
|
+
class Meta:
|
|
87
|
+
model = YourModel
|
|
88
|
+
|
|
89
|
+
fields = ('jsonfield',)
|
|
90
|
+
|
|
91
|
+
widgets = {
|
|
92
|
+
'jsonfield': JSONEditorWidget
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
Wagtail
|
|
96
|
+
-------
|
|
97
|
+
|
|
98
|
+
For a Django ``JSONField`` on a Wagtail page or snippet, pass the widget to
|
|
99
|
+
``FieldPanel``. Add ``django_json_widget`` to ``INSTALLED_APPS`` as above.
|
|
100
|
+
|
|
101
|
+
.. code-block:: python
|
|
102
|
+
|
|
103
|
+
from django.db import models
|
|
104
|
+
from wagtail.admin.panels import FieldPanel
|
|
105
|
+
from wagtail.models import Page
|
|
106
|
+
from django_json_widget.widgets import JSONEditorWidget
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class ConfigurationPage(Page):
|
|
110
|
+
configuration = models.JSONField(default=dict, blank=True)
|
|
111
|
+
|
|
112
|
+
content_panels = Page.content_panels + [
|
|
113
|
+
FieldPanel(
|
|
114
|
+
'configuration',
|
|
115
|
+
widget=JSONEditorWidget(width='100%'),
|
|
116
|
+
),
|
|
117
|
+
]
|
|
118
|
+
|
|
119
|
+
Wagtail includes the widget's JavaScript and CSS through form media. The same
|
|
120
|
+
``FieldPanel`` configuration can be used on a child model displayed through
|
|
121
|
+
``InlinePanel``; editors initialize when rows are added. Django validates the
|
|
122
|
+
submitted JSON, including invalid or cleared input.
|
|
123
|
+
|
|
124
|
+
This integration is tested with Wagtail 7.2 and Django 5.2. It covers model
|
|
125
|
+
fields rendered by panels. Using the widget inside a custom ``StreamField``
|
|
126
|
+
block requires a Wagtail Telepath widget adapter.
|
|
127
|
+
|
|
128
|
+
Configuration
|
|
129
|
+
-------------
|
|
130
|
+
|
|
131
|
+
You can customize the JSONEditorWidget with the following options:
|
|
132
|
+
|
|
133
|
+
* **width**: Width of the editor as a string with CSS size units (px, em, % etc). Defaults to ``90%``.
|
|
134
|
+
* **height**: Height of the editor as a string CSS size units. Defaults to ``550px``.
|
|
135
|
+
* **options**: A dict of options accepted by the `JSON editor`_. Options that require functions (eg. onError) are not supported.
|
|
136
|
+
* **mode (deprecated)**: The default editor mode. This argument is redundant because it can be specified as a part of ``options``. Preserved for backwards compatibility with version 0.2.0.
|
|
137
|
+
* **attrs**: HTML attributes to be applied to the wrapper element. See the `Django Widget documentation`_.
|
|
138
|
+
|
|
139
|
+
Content Security Policy
|
|
140
|
+
-----------------------
|
|
141
|
+
|
|
142
|
+
The widget loads its executable initialization code from a static JavaScript
|
|
143
|
+
file. Its initial value is embedded in a non-executable ``application/json``
|
|
144
|
+
script element. However, the bundled JSONEditor and its Ace code editor are
|
|
145
|
+
not fully compatible with a strict Content Security Policy (CSP):
|
|
146
|
+
|
|
147
|
+
* The widget and editor use inline styles, and Ace injects style elements.
|
|
148
|
+
A policy that disallows inline styles can prevent the editor from displaying
|
|
149
|
+
correctly.
|
|
150
|
+
* The default ``code`` mode creates a ``blob:`` worker. A restrictive
|
|
151
|
+
``worker-src`` can block it.
|
|
152
|
+
* JSON schema validation compiles schemas using JavaScript's ``Function``
|
|
153
|
+
constructor. A ``script-src`` that disallows ``'unsafe-eval'`` blocks this.
|
|
154
|
+
|
|
155
|
+
Consequently, allowing only ``'self'`` for scripts and styles is not sufficient
|
|
156
|
+
for all widget features. The CSP directives and relaxations needed depend on
|
|
157
|
+
the chosen editor modes and options; test the actual configuration with CSP
|
|
158
|
+
enforcement before deploying. Allowing inline styles, ``blob:`` workers, or
|
|
159
|
+
``'unsafe-eval'`` weakens a policy, so projects that cannot accept those
|
|
160
|
+
exceptions should use a different editor or provide compatible assets via
|
|
161
|
+
``JSON_EDITOR_JS`` and ``JSON_EDITOR_CSS``.
|
|
162
|
+
|
|
163
|
+
Accessing JsonEditor Instance
|
|
164
|
+
-----------------------------
|
|
165
|
+
|
|
166
|
+
The JsonEditor instance is automatically exposed for external access through two methods:
|
|
167
|
+
|
|
168
|
+
1. **Window object**: Available as ``window['FIELD_ID_editor']`` where FIELD_ID is the field's HTML ID
|
|
169
|
+
2. **DOM element**: Available as ``container.jsonEditor`` property on the widget's container element
|
|
170
|
+
|
|
171
|
+
Example usage for external JavaScript access:
|
|
172
|
+
|
|
173
|
+
.. code-block:: javascript
|
|
174
|
+
|
|
175
|
+
// Access via window object
|
|
176
|
+
var editor = window['id_jsonfield_editor'];
|
|
177
|
+
editor.set({'key': 'new value'});
|
|
178
|
+
|
|
179
|
+
// Access via DOM element
|
|
180
|
+
var container = document.getElementById('id_jsonfield');
|
|
181
|
+
var editor = container.jsonEditor;
|
|
182
|
+
editor.set({'key': 'new value'});
|
|
183
|
+
|
|
184
|
+
This allows you to programmatically call JsonEditor methods like ``set()``, ``get()``, ``update()``, etc. from custom JavaScript code running in your admin pages or forms.
|
|
185
|
+
|
|
186
|
+
.. _json editor: https://github.com/josdejong/jsoneditor/blob/master/docs/api.md#configuration-options
|
|
187
|
+
.. _Django Widget documentation: https://docs.djangoproject.com/en/2.1/ref/forms/widgets/#django.forms.Widget.attrs
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
JSONEditorWidget widget
|
|
191
|
+
-----------------------
|
|
192
|
+
|
|
193
|
+
Before:
|
|
194
|
+
|
|
195
|
+
.. image:: https://raw.githubusercontent.com/jmrivas86/django-json-widget/master/imgs/jsonfield_0.png
|
|
196
|
+
|
|
197
|
+
After:
|
|
198
|
+
|
|
199
|
+
.. image:: https://raw.githubusercontent.com/jmrivas86/django-json-widget/master/imgs/jsonfield_1.png
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
Development Guide
|
|
203
|
+
-----------------
|
|
204
|
+
|
|
205
|
+
Read the contribution guide.
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
Credits
|
|
209
|
+
-------
|
|
210
|
+
|
|
211
|
+
Tools used in rendering this package:
|
|
212
|
+
|
|
213
|
+
* Cookiecutter_
|
|
214
|
+
* `cookiecutter-djangopackage`_
|
|
215
|
+
|
|
216
|
+
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
|
|
217
|
+
.. _`cookiecutter-djangopackage`: https://github.com/pydanny/cookiecutter-djangopackage
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
=========
|
|
221
|
+
Changelog
|
|
222
|
+
=========
|
|
223
|
+
|
|
224
|
+
2.2.0 (2026-11-13)
|
|
225
|
+
------------------
|
|
226
|
+
|
|
227
|
+
* Added CSP guide.
|
|
228
|
+
* Implemented Wagtail support.
|
|
229
|
+
* Fixed inline editors.
|
|
230
|
+
|
|
231
|
+
2.1.1 (2025-12-12)
|
|
232
|
+
------------------
|
|
233
|
+
|
|
234
|
+
* Issue #108: respect Django admin color scheme setting for JSON editor.
|
|
235
|
+
|
|
236
|
+
2.1.0 (2025-10-24)
|
|
237
|
+
------------------
|
|
238
|
+
|
|
239
|
+
* Issue #114: expose editor instance to window object and DOM element.
|
|
240
|
+
|
|
241
|
+
2.0.4 (2025-10-11)
|
|
242
|
+
------------------
|
|
243
|
+
|
|
244
|
+
* Fix dark mode CSS support #107
|
|
245
|
+
|
|
246
|
+
2.0.3 (2025-07-29)
|
|
247
|
+
------------------
|
|
248
|
+
|
|
249
|
+
2.0.2 (2025-07-28)
|
|
250
|
+
------------------
|
|
251
|
+
|
|
252
|
+
* Fix Version 2.0.1 causes rendering HTML scripts issue #80
|
|
253
|
+
|
|
254
|
+
2.0.1 (2024-03-02)
|
|
255
|
+
------------------=
|
|
256
|
+
|
|
257
|
+
* Fixed Version 2.0.0 causes issues with Django 4.x due to missing sourcemaps issue #83
|
|
258
|
+
|
|
259
|
+
2.0.0 (2024-03-24)
|
|
260
|
+
------------------
|
|
261
|
+
|
|
262
|
+
* Fix default paths for static files #53
|
|
263
|
+
* Stop declaring support for Django versions before 3.2 #65
|
|
264
|
+
* Avoid HTML injection via unsafe JSON injection #64
|
|
265
|
+
* Remove source map reference from JS bundle #70
|
|
266
|
+
* Add dark mode CSS support #82
|
|
267
|
+
* Updated documentation
|
|
268
|
+
|
|
269
|
+
1.1.1 (2021-02-17)
|
|
270
|
+
------------------
|
|
271
|
+
|
|
272
|
+
* Fix for issue #51, updates the bundled libs to 9.1.9 and additional notes for Django 3.1 changes
|
|
273
|
+
|
|
274
|
+
1.1.0 (2021-02-05)
|
|
275
|
+
------------------
|
|
276
|
+
|
|
277
|
+
* Added functionality to override version of JSONEditor to use
|
|
278
|
+
* update readme for django 3.1
|
|
279
|
+
|
|
280
|
+
1.0.1 (2020-04-17)
|
|
281
|
+
------------------
|
|
282
|
+
|
|
283
|
+
* Stop resolving paths to the static files
|
|
284
|
+
|
|
285
|
+
1.0.0 (2020-01-16)
|
|
286
|
+
------------------
|
|
287
|
+
|
|
288
|
+
* Update Makefile
|
|
289
|
+
* Make Stable the project
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
0.3.0 (2020-01-16)
|
|
293
|
+
------------------
|
|
294
|
+
|
|
295
|
+
* Update requirements.txt
|
|
296
|
+
* Fixed static to work with CDN tools like django-storages
|
|
297
|
+
* Make widget more configurable
|
|
298
|
+
* Fixed an incompatibility with Python 2.7
|
|
299
|
+
* update jsoneditor to latest version
|
|
300
|
+
|
|
301
|
+
|