django-json-widget 2.0.3__tar.gz → 2.1.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.1.0/.coveragerc +11 -0
- django_json_widget-2.1.0/.editorconfig +23 -0
- django_json_widget-2.1.0/.github/ISSUE_TEMPLATE.md +16 -0
- django_json_widget-2.1.0/.github/workflows/tests.yml +31 -0
- django_json_widget-2.1.0/.gitignore +57 -0
- django_json_widget-2.1.0/.travis.yml +57 -0
- {django_json_widget-2.0.3 → django_json_widget-2.1.0}/CHANGELOG.rst +10 -0
- django_json_widget-2.1.0/CONTRIBUTING.md +83 -0
- {django_json_widget-2.0.3 → django_json_widget-2.1.0}/MANIFEST.in +1 -1
- django_json_widget-2.1.0/Makefile +66 -0
- {django_json_widget-2.0.3 → django_json_widget-2.1.0}/PKG-INFO +42 -9
- {django_json_widget-2.0.3 → django_json_widget-2.1.0}/README.rst +29 -5
- django_json_widget-2.1.0/django_json_widget/__init__.py +1 -0
- {django_json_widget-2.0.3 → django_json_widget-2.1.0}/django_json_widget/static/dist/jsoneditor.min.css +1 -1
- {django_json_widget-2.0.3 → django_json_widget-2.1.0}/django_json_widget/templates/django_json_widget.html +4 -0
- {django_json_widget-2.0.3 → django_json_widget-2.1.0}/django_json_widget/widgets.py +5 -3
- {django_json_widget-2.0.3 → django_json_widget-2.1.0}/django_json_widget.egg-info/PKG-INFO +42 -9
- django_json_widget-2.1.0/django_json_widget.egg-info/SOURCES.txt +62 -0
- django_json_widget-2.1.0/example/README.md +24 -0
- django_json_widget-2.1.0/example/characters/__init__.py +0 -0
- django_json_widget-2.1.0/example/characters/admin.py +11 -0
- django_json_widget-2.1.0/example/characters/apps.py +5 -0
- django_json_widget-2.1.0/example/characters/migrations/0001_initial.py +24 -0
- django_json_widget-2.1.0/example/characters/migrations/0002_alter_character_data_alter_character_other_data.py +23 -0
- django_json_widget-2.1.0/example/characters/migrations/__init__.py +0 -0
- django_json_widget-2.1.0/example/characters/models.py +11 -0
- django_json_widget-2.1.0/example/characters/tests.py +3 -0
- django_json_widget-2.1.0/example/characters/views.py +3 -0
- django_json_widget-2.1.0/example/example/__init__.py +0 -0
- django_json_widget-2.1.0/example/example/settings.py +111 -0
- django_json_widget-2.1.0/example/example/urls.py +21 -0
- django_json_widget-2.1.0/example/example/wsgi.py +16 -0
- django_json_widget-2.1.0/example/manage.py +21 -0
- django_json_widget-2.1.0/example/requirements.txt +5 -0
- django_json_widget-2.1.0/example/templates/django_json_widget/base.html +88 -0
- django_json_widget-2.1.0/imgs/jsonfield_0.png +0 -0
- django_json_widget-2.1.0/imgs/jsonfield_1.png +0 -0
- django_json_widget-2.1.0/manage.py +10 -0
- django_json_widget-2.1.0/pyproject.toml +153 -0
- django_json_widget-2.1.0/requirements.txt +1 -0
- django_json_widget-2.1.0/requirements_dev.txt +9 -0
- django_json_widget-2.1.0/requirements_test.txt +7 -0
- django_json_widget-2.1.0/setup.cfg +16 -0
- {django_json_widget-2.0.3 → django_json_widget-2.1.0}/setup.py +3 -4
- django_json_widget-2.1.0/tests/__init__.py +0 -0
- django_json_widget-2.1.0/tests/settings.py +49 -0
- django_json_widget-2.1.0/tests/templates/django/forms/widgets/attrs.html +1 -0
- django_json_widget-2.1.0/tests/test_jsoneditor_access.py +60 -0
- django_json_widget-2.1.0/tests/test_logic.py +317 -0
- django_json_widget-2.1.0/tests/test_widget_security.py +162 -0
- django_json_widget-2.1.0/tox.ini +26 -0
- django_json_widget-2.0.3/CONTRIBUTING.rst +0 -113
- django_json_widget-2.0.3/django_json_widget/__init__.py +0 -1
- django_json_widget-2.0.3/django_json_widget.egg-info/SOURCES.txt +0 -25
- django_json_widget-2.0.3/setup.cfg +0 -27
- django_json_widget-2.0.3/tests/test_models.py +0 -23
- {django_json_widget-2.0.3 → django_json_widget-2.1.0}/AUTHORS.rst +0 -0
- {django_json_widget-2.0.3 → django_json_widget-2.1.0}/LICENSE +0 -0
- {django_json_widget-2.0.3 → django_json_widget-2.1.0}/django_json_widget/apps.py +0 -0
- {django_json_widget-2.0.3 → django_json_widget-2.1.0}/django_json_widget/models.py +0 -0
- {django_json_widget-2.0.3 → django_json_widget-2.1.0}/django_json_widget/static/css/django_json_widget.css +0 -0
- {django_json_widget-2.0.3 → django_json_widget-2.1.0}/django_json_widget/static/dist/img/jsoneditor-icons.svg +0 -0
- {django_json_widget-2.0.3 → django_json_widget-2.1.0}/django_json_widget/static/dist/jsoneditor.min.js +0 -0
- {django_json_widget-2.0.3 → django_json_widget-2.1.0}/django_json_widget/urls.py +0 -0
- {django_json_widget-2.0.3 → django_json_widget-2.1.0}/django_json_widget/views.py +0 -0
- {django_json_widget-2.0.3 → django_json_widget-2.1.0}/django_json_widget.egg-info/dependency_links.txt +0 -0
- {django_json_widget-2.0.3 → django_json_widget-2.1.0}/django_json_widget.egg-info/not-zip-safe +0 -0
- {django_json_widget-2.0.3 → django_json_widget-2.1.0}/django_json_widget.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# http://editorconfig.org
|
|
2
|
+
|
|
3
|
+
root = true
|
|
4
|
+
|
|
5
|
+
[*]
|
|
6
|
+
charset = utf-8
|
|
7
|
+
end_of_line = lf
|
|
8
|
+
insert_final_newline = true
|
|
9
|
+
trim_trailing_whitespace = true
|
|
10
|
+
|
|
11
|
+
[*.{py,rst,ini}]
|
|
12
|
+
indent_style = space
|
|
13
|
+
indent_size = 4
|
|
14
|
+
|
|
15
|
+
[*.{html,css,scss,json,yml}]
|
|
16
|
+
indent_style = space
|
|
17
|
+
indent_size = 2
|
|
18
|
+
|
|
19
|
+
[*.md]
|
|
20
|
+
trim_trailing_whitespace = false
|
|
21
|
+
|
|
22
|
+
[Makefile]
|
|
23
|
+
indent_style = tab
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
* django-json-widget version:
|
|
2
|
+
* Django version:
|
|
3
|
+
* Python version:
|
|
4
|
+
* Operating System:
|
|
5
|
+
|
|
6
|
+
### Description
|
|
7
|
+
|
|
8
|
+
Describe what you were trying to get done.
|
|
9
|
+
Tell us what happened, what went wrong, and what you expected to happen.
|
|
10
|
+
|
|
11
|
+
### What I Did
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
Paste the command(s) you ran and the output.
|
|
15
|
+
If there was a crash, please include the traceback here.
|
|
16
|
+
```
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ master ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ master ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
strategy:
|
|
14
|
+
max-parallel: 5
|
|
15
|
+
matrix:
|
|
16
|
+
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
21
|
+
uses: actions/setup-python@v4
|
|
22
|
+
with:
|
|
23
|
+
python-version: ${{ matrix.python-version }}
|
|
24
|
+
|
|
25
|
+
- name: Install dependencies
|
|
26
|
+
run: |
|
|
27
|
+
python -m pip install --upgrade pip
|
|
28
|
+
python -m pip install tox tox-gh-actions
|
|
29
|
+
|
|
30
|
+
- name: Run tests
|
|
31
|
+
run: tox
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
*.py[cod]
|
|
2
|
+
__pycache__
|
|
3
|
+
|
|
4
|
+
# C extensions
|
|
5
|
+
*.so
|
|
6
|
+
|
|
7
|
+
# Packages
|
|
8
|
+
*.egg
|
|
9
|
+
*.egg-info
|
|
10
|
+
build
|
|
11
|
+
eggs
|
|
12
|
+
parts
|
|
13
|
+
bin
|
|
14
|
+
var
|
|
15
|
+
sdist
|
|
16
|
+
develop-eggs
|
|
17
|
+
.installed.cfg
|
|
18
|
+
lib
|
|
19
|
+
lib64
|
|
20
|
+
.pypirc
|
|
21
|
+
|
|
22
|
+
# Installer logs
|
|
23
|
+
pip-log.txt
|
|
24
|
+
|
|
25
|
+
# Unit test / coverage reports
|
|
26
|
+
.coverage
|
|
27
|
+
.tox
|
|
28
|
+
nosetests.xml
|
|
29
|
+
htmlcov
|
|
30
|
+
|
|
31
|
+
# Translations
|
|
32
|
+
*.mo
|
|
33
|
+
|
|
34
|
+
# Mr Developer
|
|
35
|
+
.mr.developer.cfg
|
|
36
|
+
.project
|
|
37
|
+
.pydevproject
|
|
38
|
+
|
|
39
|
+
# Pycharm/Intellij
|
|
40
|
+
.idea
|
|
41
|
+
|
|
42
|
+
# Complexity
|
|
43
|
+
output/*.html
|
|
44
|
+
output/*/index.html
|
|
45
|
+
|
|
46
|
+
# Sphinx
|
|
47
|
+
docs/_build
|
|
48
|
+
/.tox/
|
|
49
|
+
/dist/
|
|
50
|
+
|
|
51
|
+
# venv
|
|
52
|
+
/.pypirc
|
|
53
|
+
/example/.python-version
|
|
54
|
+
|
|
55
|
+
# OS
|
|
56
|
+
.DS_Store
|
|
57
|
+
example/.DS_Store
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Config file for automatic testing at travis-ci.org
|
|
2
|
+
|
|
3
|
+
language: python
|
|
4
|
+
|
|
5
|
+
python:
|
|
6
|
+
- "3.6"
|
|
7
|
+
- "3.7"
|
|
8
|
+
- "3.8"
|
|
9
|
+
- "3.9"
|
|
10
|
+
- "3.10"
|
|
11
|
+
- "3.11"
|
|
12
|
+
- "3.12"
|
|
13
|
+
|
|
14
|
+
matrix:
|
|
15
|
+
fast_finish: true
|
|
16
|
+
include:
|
|
17
|
+
# DJANGO 3.2.25
|
|
18
|
+
- python: 3.6
|
|
19
|
+
env: DJANGO_VERSION=3.2.25
|
|
20
|
+
- python: 3.7
|
|
21
|
+
env: DJANGO_VERSION=3.2.25
|
|
22
|
+
- python: 3.8
|
|
23
|
+
env: DJANGO_VERSION=3.2.25
|
|
24
|
+
- python: 3.9
|
|
25
|
+
env: DJANGO_VERSION=3.2.25
|
|
26
|
+
- python: 3.10
|
|
27
|
+
env: DJANGO_VERSION=3.2.25
|
|
28
|
+
# DJANGO 4.2.11
|
|
29
|
+
env: DJANGO_VERSION=3.2.25
|
|
30
|
+
- python: 3.8
|
|
31
|
+
env: DJANGO_VERSION=3.2.25
|
|
32
|
+
- python: 3.9
|
|
33
|
+
env: DJANGO_VERSION=3.2.25
|
|
34
|
+
- python: 3.10
|
|
35
|
+
env: DJANGO_VERSION=3.2.25
|
|
36
|
+
- python: 3.11
|
|
37
|
+
env: DJANGO_VERSION=3.2.25
|
|
38
|
+
- python: 3.12
|
|
39
|
+
env: DJANGO_VERSION=3.2.25
|
|
40
|
+
# DJANGO 5.0.3
|
|
41
|
+
- python: 3.10
|
|
42
|
+
env: DJANGO_VERSION=3.2.25
|
|
43
|
+
- python: 3.11
|
|
44
|
+
env: DJANGO_VERSION=3.2.25
|
|
45
|
+
- python: 3.12
|
|
46
|
+
env: DJANGO_VERSION=3.2.25
|
|
47
|
+
# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
|
|
48
|
+
install:
|
|
49
|
+
- echo "$DJANGO_VERSION"
|
|
50
|
+
- pip install -r requirements_test.txt
|
|
51
|
+
|
|
52
|
+
# command to run tests using coverage, e.g. python setup.py test
|
|
53
|
+
script: coverage run --source django_json_widget runtests.py
|
|
54
|
+
# script: tox -e $TOX_ENV
|
|
55
|
+
|
|
56
|
+
# after_success:
|
|
57
|
+
# - codecov -e TOX_ENV
|
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
Changelog
|
|
3
3
|
=========
|
|
4
4
|
|
|
5
|
+
2.1.0 (2025-10-24)
|
|
6
|
+
------------------
|
|
7
|
+
|
|
8
|
+
* Issue #114: expose editor instance to window object and DOM element.
|
|
9
|
+
|
|
10
|
+
2.0.4 (2025-10-11)
|
|
11
|
+
------------------
|
|
12
|
+
|
|
13
|
+
* Fix dark mode CSS support #107
|
|
14
|
+
|
|
5
15
|
2.0.3 (2025-07-29)
|
|
6
16
|
------------------
|
|
7
17
|
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
|
|
4
|
+
|
|
5
|
+
You can contribute in many ways:
|
|
6
|
+
|
|
7
|
+
## Types of Contributions
|
|
8
|
+
|
|
9
|
+
### Report Bugs
|
|
10
|
+
|
|
11
|
+
Report bugs at https://github.com/jmrivas86/django-json-widget/issues.
|
|
12
|
+
|
|
13
|
+
If you are reporting a bug, please include:
|
|
14
|
+
|
|
15
|
+
* Your operating system name and version.
|
|
16
|
+
* Any details about your local setup that might be helpful in troubleshooting.
|
|
17
|
+
* Detailed steps to reproduce the bug.
|
|
18
|
+
|
|
19
|
+
### Fix Bugs
|
|
20
|
+
|
|
21
|
+
Look through the GitHub issues for bugs. Anything tagged with "bug" is open to whoever wants to implement it.
|
|
22
|
+
|
|
23
|
+
### Implement Features
|
|
24
|
+
|
|
25
|
+
Look through the GitHub issues for features. Anything tagged with "feature" is open to whoever wants to implement it.
|
|
26
|
+
|
|
27
|
+
### Write Documentation
|
|
28
|
+
|
|
29
|
+
django-json-widget could always use more documentation, whether as part of the official django-json-widget docs, in docstrings, or even on the web in blog posts, articles, and such.
|
|
30
|
+
|
|
31
|
+
### Submit Feedback
|
|
32
|
+
|
|
33
|
+
The best way to send feedback is to file an issue at https://github.com/jmrivas86/django-json-widget/issues.
|
|
34
|
+
|
|
35
|
+
If you are proposing a feature:
|
|
36
|
+
|
|
37
|
+
* Explain in detail how it would work.
|
|
38
|
+
* Keep the scope as narrow as possible, to make it easier to implement.
|
|
39
|
+
* Remember that this is a volunteer-driven project, and that contributions are welcome :)
|
|
40
|
+
|
|
41
|
+
## Get Started!
|
|
42
|
+
|
|
43
|
+
Ready to contribute? Here's how to set up `django-json-widget` for local development.
|
|
44
|
+
|
|
45
|
+
1. Fork the `django-json-widget` repo on GitHub.
|
|
46
|
+
|
|
47
|
+
2. Clone your fork locally:
|
|
48
|
+
```bash
|
|
49
|
+
git clone git@github.com:your_name_here/django-json-widget.git
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
3. Install development dependencies:
|
|
53
|
+
```bash
|
|
54
|
+
cd django-json-widget/
|
|
55
|
+
python -m venv .venv
|
|
56
|
+
source .venv/bin/activate
|
|
57
|
+
pip install -r requirements_test.txt
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
4. Create a branch for local development from the dev branch:
|
|
61
|
+
```bash
|
|
62
|
+
git checkout dev
|
|
63
|
+
git checkout -b name-of-your-branch
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Now you can make your changes locally.
|
|
67
|
+
|
|
68
|
+
5. Commit your changes and push your branch:
|
|
69
|
+
```bash
|
|
70
|
+
git add .
|
|
71
|
+
git commit -m "Your detailed description of your changes."
|
|
72
|
+
git push origin name-of-your-branch
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
6. Submit a pull request through the GitHub website.
|
|
76
|
+
|
|
77
|
+
## Pull Request Guidelines
|
|
78
|
+
|
|
79
|
+
Before you submit a pull request, check that it meets these guidelines:
|
|
80
|
+
|
|
81
|
+
1. **The pull request must be submitted against the `dev` branch.**
|
|
82
|
+
2. Please explain what you have done in the pull request.
|
|
83
|
+
3. Make sure you have had passed pre-commit hooks.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
.PHONY: clean-pyc clean-build docs help
|
|
2
|
+
.DEFAULT_GOAL := help
|
|
3
|
+
define BROWSER_PYSCRIPT
|
|
4
|
+
import os, webbrowser, sys
|
|
5
|
+
try:
|
|
6
|
+
from urllib import pathname2url
|
|
7
|
+
except:
|
|
8
|
+
from urllib.request import pathname2url
|
|
9
|
+
|
|
10
|
+
webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
|
|
11
|
+
endef
|
|
12
|
+
export BROWSER_PYSCRIPT
|
|
13
|
+
BROWSER := python -c "$$BROWSER_PYSCRIPT"
|
|
14
|
+
|
|
15
|
+
help:
|
|
16
|
+
@perl -nle'print $& if m{^[a-zA-Z_-]+:.*?## .*$$}' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-25s\033[0m %s\n", $$1, $$2}'
|
|
17
|
+
|
|
18
|
+
clean: clean-build clean-pyc
|
|
19
|
+
|
|
20
|
+
clean-build: ## remove build artifacts
|
|
21
|
+
rm -fr build/
|
|
22
|
+
rm -fr dist/
|
|
23
|
+
rm -fr *.egg-info
|
|
24
|
+
|
|
25
|
+
clean-pyc: ## remove Python file artifacts
|
|
26
|
+
find . -name '*.pyc' -exec rm -f {} +
|
|
27
|
+
find . -name '*.pyo' -exec rm -f {} +
|
|
28
|
+
find . -name '*~' -exec rm -f {} +
|
|
29
|
+
|
|
30
|
+
lint: ## check style with flake8
|
|
31
|
+
flake8 django_json_widget tests
|
|
32
|
+
|
|
33
|
+
test: ## run tests quickly with the default Python
|
|
34
|
+
python runtests.py tests
|
|
35
|
+
|
|
36
|
+
test-all: ## run tests on every Python version with tox
|
|
37
|
+
tox
|
|
38
|
+
|
|
39
|
+
coverage: ## check code coverage quickly with the default Python
|
|
40
|
+
coverage run --source django_json_widget runtests.py tests
|
|
41
|
+
coverage report -m
|
|
42
|
+
coverage html
|
|
43
|
+
open htmlcov/index.html
|
|
44
|
+
|
|
45
|
+
docs: ## generate Sphinx HTML documentation, including API docs
|
|
46
|
+
rm -f docs/django-json-widget.rst
|
|
47
|
+
rm -f docs/modules.rst
|
|
48
|
+
sphinx-apidoc -o docs/ django_json_widget
|
|
49
|
+
$(MAKE) -C docs clean
|
|
50
|
+
$(MAKE) -C docs html
|
|
51
|
+
$(BROWSER) docs/_build/html/index.html
|
|
52
|
+
|
|
53
|
+
release: clean ## package and upload a release
|
|
54
|
+
python -m build
|
|
55
|
+
twine upload dist/*
|
|
56
|
+
|
|
57
|
+
test-release: clean ## package and upload a release to test PyPI
|
|
58
|
+
python -m build
|
|
59
|
+
twine upload --repository testpypi dist/*
|
|
60
|
+
|
|
61
|
+
sdist: clean ## package
|
|
62
|
+
python -m build --sdist
|
|
63
|
+
ls -l dist
|
|
64
|
+
|
|
65
|
+
twine-release: ## upload release to pypi
|
|
66
|
+
twine upload dist/*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: django-json-widget
|
|
3
|
-
Version: 2.0
|
|
3
|
+
Version: 2.1.0
|
|
4
4
|
Summary: Django json widget is an alternative widget that makes it easy to edit the jsonfield field of django.
|
|
5
5
|
Home-page: https://github.com/jmrivas86/django-json-widget
|
|
6
6
|
Author: José Manuel Rivas
|
|
@@ -12,17 +12,16 @@ Classifier: Framework :: Django
|
|
|
12
12
|
Classifier: Framework :: Django :: 3.2
|
|
13
13
|
Classifier: Framework :: Django :: 4.2
|
|
14
14
|
Classifier: Framework :: Django :: 5.0
|
|
15
|
+
Classifier: Framework :: Django :: 5.2
|
|
15
16
|
Classifier: Intended Audience :: Developers
|
|
16
17
|
Classifier: License :: OSI Approved :: BSD License
|
|
17
18
|
Classifier: Natural Language :: English
|
|
18
19
|
Classifier: Programming Language :: Python :: 3
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.6
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
22
20
|
Classifier: Programming Language :: Python :: 3.9
|
|
23
21
|
Classifier: Programming Language :: Python :: 3.10
|
|
24
22
|
Classifier: Programming Language :: Python :: 3.11
|
|
25
23
|
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
26
25
|
License-File: LICENSE
|
|
27
26
|
License-File: AUTHORS.rst
|
|
28
27
|
Dynamic: author
|
|
@@ -42,11 +41,6 @@ django-json-widget
|
|
|
42
41
|
.. image:: https://badge.fury.io/py/django-json-widget.svg
|
|
43
42
|
:target: https://badge.fury.io/py/django-json-widget
|
|
44
43
|
|
|
45
|
-
.. image:: https://travis-ci.org/jmrivas86/django-json-widget.svg?branch=master
|
|
46
|
-
:target: https://travis-ci.org/jmrivas86/django-json-widget
|
|
47
|
-
|
|
48
|
-
.. image:: https://codecov.io/gh/jmrivas86/django-json-widget/branch/master/graph/badge.svg
|
|
49
|
-
:target: https://codecov.io/gh/jmrivas86/django-json-widget
|
|
50
44
|
|
|
51
45
|
An alternative widget that makes it easy to edit the new Django's field JSONField (PostgreSQL specific model fields)
|
|
52
46
|
|
|
@@ -114,6 +108,29 @@ You can customize the JSONEditorWidget with the following options:
|
|
|
114
108
|
* **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.
|
|
115
109
|
* **attrs**: HTML attributes to be applied to the wrapper element. See the `Django Widget documentation`_.
|
|
116
110
|
|
|
111
|
+
Accessing JsonEditor Instance
|
|
112
|
+
-----------------------------
|
|
113
|
+
|
|
114
|
+
The JsonEditor instance is automatically exposed for external access through two methods:
|
|
115
|
+
|
|
116
|
+
1. **Window object**: Available as ``window['FIELD_ID_editor']`` where FIELD_ID is the field's HTML ID
|
|
117
|
+
2. **DOM element**: Available as ``container.jsonEditor`` property on the widget's container element
|
|
118
|
+
|
|
119
|
+
Example usage for external JavaScript access:
|
|
120
|
+
|
|
121
|
+
.. code-block:: javascript
|
|
122
|
+
|
|
123
|
+
// Access via window object
|
|
124
|
+
var editor = window['id_jsonfield_editor'];
|
|
125
|
+
editor.set({'key': 'new value'});
|
|
126
|
+
|
|
127
|
+
// Access via DOM element
|
|
128
|
+
var container = document.getElementById('id_jsonfield');
|
|
129
|
+
var editor = container.jsonEditor;
|
|
130
|
+
editor.set({'key': 'new value'});
|
|
131
|
+
|
|
132
|
+
This allows you to programmatically call JsonEditor methods like ``set()``, ``get()``, ``update()``, etc. from custom JavaScript code running in your admin pages or forms.
|
|
133
|
+
|
|
117
134
|
.. _json editor: https://github.com/josdejong/jsoneditor/blob/master/docs/api.md#configuration-options
|
|
118
135
|
.. _Django Widget documentation: https://docs.djangoproject.com/en/2.1/ref/forms/widgets/#django.forms.Widget.attrs
|
|
119
136
|
|
|
@@ -130,6 +147,12 @@ After:
|
|
|
130
147
|
.. image:: https://raw.githubusercontent.com/jmrivas86/django-json-widget/master/imgs/jsonfield_1.png
|
|
131
148
|
|
|
132
149
|
|
|
150
|
+
Development Guide
|
|
151
|
+
-----------------
|
|
152
|
+
|
|
153
|
+
Read the contribution guide.
|
|
154
|
+
|
|
155
|
+
|
|
133
156
|
Credits
|
|
134
157
|
-------
|
|
135
158
|
|
|
@@ -146,6 +169,16 @@ Tools used in rendering this package:
|
|
|
146
169
|
Changelog
|
|
147
170
|
=========
|
|
148
171
|
|
|
172
|
+
2.1.0 (2025-10-24)
|
|
173
|
+
------------------
|
|
174
|
+
|
|
175
|
+
* Issue #114: expose editor instance to window object and DOM element.
|
|
176
|
+
|
|
177
|
+
2.0.4 (2025-10-11)
|
|
178
|
+
------------------
|
|
179
|
+
|
|
180
|
+
* Fix dark mode CSS support #107
|
|
181
|
+
|
|
149
182
|
2.0.3 (2025-07-29)
|
|
150
183
|
------------------
|
|
151
184
|
|
|
@@ -5,11 +5,6 @@ django-json-widget
|
|
|
5
5
|
.. image:: https://badge.fury.io/py/django-json-widget.svg
|
|
6
6
|
:target: https://badge.fury.io/py/django-json-widget
|
|
7
7
|
|
|
8
|
-
.. image:: https://travis-ci.org/jmrivas86/django-json-widget.svg?branch=master
|
|
9
|
-
:target: https://travis-ci.org/jmrivas86/django-json-widget
|
|
10
|
-
|
|
11
|
-
.. image:: https://codecov.io/gh/jmrivas86/django-json-widget/branch/master/graph/badge.svg
|
|
12
|
-
:target: https://codecov.io/gh/jmrivas86/django-json-widget
|
|
13
8
|
|
|
14
9
|
An alternative widget that makes it easy to edit the new Django's field JSONField (PostgreSQL specific model fields)
|
|
15
10
|
|
|
@@ -77,6 +72,29 @@ You can customize the JSONEditorWidget with the following options:
|
|
|
77
72
|
* **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.
|
|
78
73
|
* **attrs**: HTML attributes to be applied to the wrapper element. See the `Django Widget documentation`_.
|
|
79
74
|
|
|
75
|
+
Accessing JsonEditor Instance
|
|
76
|
+
-----------------------------
|
|
77
|
+
|
|
78
|
+
The JsonEditor instance is automatically exposed for external access through two methods:
|
|
79
|
+
|
|
80
|
+
1. **Window object**: Available as ``window['FIELD_ID_editor']`` where FIELD_ID is the field's HTML ID
|
|
81
|
+
2. **DOM element**: Available as ``container.jsonEditor`` property on the widget's container element
|
|
82
|
+
|
|
83
|
+
Example usage for external JavaScript access:
|
|
84
|
+
|
|
85
|
+
.. code-block:: javascript
|
|
86
|
+
|
|
87
|
+
// Access via window object
|
|
88
|
+
var editor = window['id_jsonfield_editor'];
|
|
89
|
+
editor.set({'key': 'new value'});
|
|
90
|
+
|
|
91
|
+
// Access via DOM element
|
|
92
|
+
var container = document.getElementById('id_jsonfield');
|
|
93
|
+
var editor = container.jsonEditor;
|
|
94
|
+
editor.set({'key': 'new value'});
|
|
95
|
+
|
|
96
|
+
This allows you to programmatically call JsonEditor methods like ``set()``, ``get()``, ``update()``, etc. from custom JavaScript code running in your admin pages or forms.
|
|
97
|
+
|
|
80
98
|
.. _json editor: https://github.com/josdejong/jsoneditor/blob/master/docs/api.md#configuration-options
|
|
81
99
|
.. _Django Widget documentation: https://docs.djangoproject.com/en/2.1/ref/forms/widgets/#django.forms.Widget.attrs
|
|
82
100
|
|
|
@@ -93,6 +111,12 @@ After:
|
|
|
93
111
|
.. image:: https://raw.githubusercontent.com/jmrivas86/django-json-widget/master/imgs/jsonfield_1.png
|
|
94
112
|
|
|
95
113
|
|
|
114
|
+
Development Guide
|
|
115
|
+
-----------------
|
|
116
|
+
|
|
117
|
+
Read the contribution guide.
|
|
118
|
+
|
|
119
|
+
|
|
96
120
|
Credits
|
|
97
121
|
-------
|
|
98
122
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '2.1.0'
|
|
@@ -6,4 +6,4 @@
|
|
|
6
6
|
*/.selectr-container{position:relative}.selectr-container li{list-style:none}.selectr-hidden{position:absolute;overflow:hidden;clip:rect(0,0,0,0);width:1px;height:1px;margin:-1px;padding:0;border:0 none}.selectr-visible{position:absolute;left:0;top:0;width:100%;height:100%;opacity:0;z-index:11}.selectr-desktop.multiple .selectr-visible{display:none}.selectr-desktop.multiple.native-open .selectr-visible{top:100%;min-height:200px!important;height:auto;opacity:1;display:block}.selectr-container.multiple.selectr-mobile .selectr-selected{z-index:0}.selectr-selected{position:relative;z-index:1;box-sizing:border-box;width:100%;padding:7px 28px 7px 14px;cursor:pointer;border:1px solid #999;border-radius:3px;background-color:#fff}.selectr-selected::before{position:absolute;top:50%;right:10px;width:0;height:0;content:"";-o-transform:rotate(0) translate3d(0,-50%,0);-ms-transform:rotate(0) translate3d(0,-50%,0);-moz-transform:rotate(0) translate3d(0,-50%,0);-webkit-transform:rotate(0) translate3d(0,-50%,0);transform:rotate(0) translate3d(0,-50%,0);border-width:4px 4px 0 4px;border-style:solid;border-color:#6c7a86 transparent transparent}.selectr-container.native-open .selectr-selected::before,.selectr-container.open .selectr-selected::before{border-width:0 4px 4px 4px;border-style:solid;border-color:transparent transparent #6c7a86}.selectr-label{display:none;overflow:hidden;width:100%;white-space:nowrap;text-overflow:ellipsis}.selectr-placeholder{color:#6c7a86}.selectr-tags{margin:0;padding:0;white-space:normal}.has-selected .selectr-tags{margin:0 0 -2px}.selectr-tag{list-style:none;position:relative;float:left;padding:2px 25px 2px 8px;margin:0 2px 2px 0;cursor:default;color:#fff;border:medium none;border-radius:10px;background:#acb7bf none repeat scroll 0 0}.selectr-container.multiple.has-selected .selectr-selected{padding:5px 28px 5px 5px}.selectr-options-container{position:absolute;z-index:10000;top:calc(100% - 1px);left:0;display:none;box-sizing:border-box;width:100%;border-width:0 1px 1px;border-style:solid;border-color:transparent #999 #999;border-radius:0 0 3px 3px;background-color:#fff}.selectr-container.open .selectr-options-container{display:block}.selectr-input-container{position:relative;display:none}.selectr-clear,.selectr-input-clear,.selectr-tag-remove{position:absolute;top:50%;right:22px;width:20px;height:20px;padding:0;cursor:pointer;-o-transform:translate3d(0,-50%,0);-ms-transform:translate3d(0,-50%,0);-moz-transform:translate3d(0,-50%,0);-webkit-transform:translate3d(0,-50%,0);transform:translate3d(0,-50%,0);border:medium none;background-color:transparent;z-index:11}.selectr-clear,.selectr-input-clear{display:none}.selectr-container.has-selected .selectr-clear,.selectr-input-container.active .selectr-input-clear{display:block}.selectr-selected .selectr-tag-remove{right:2px}.selectr-clear::after,.selectr-clear::before,.selectr-input-clear::after,.selectr-input-clear::before,.selectr-tag-remove::after,.selectr-tag-remove::before{position:absolute;top:5px;left:9px;width:2px;height:10px;content:" ";background-color:#6c7a86}.selectr-tag-remove::after,.selectr-tag-remove::before{top:4px;width:3px;height:12px;background-color:#fff}.selectr-clear:before,.selectr-input-clear::before,.selectr-tag-remove::before{-o-transform:rotate(45deg);-ms-transform:rotate(45deg);-moz-transform:rotate(45deg);-webkit-transform:rotate(45deg);transform:rotate(45deg)}.selectr-clear:after,.selectr-input-clear::after,.selectr-tag-remove::after{-o-transform:rotate(-45deg);-ms-transform:rotate(-45deg);-moz-transform:rotate(-45deg);-webkit-transform:rotate(-45deg);transform:rotate(-45deg)}.selectr-input-container.active,.selectr-input-container.active .selectr-clear{display:block}.selectr-input{top:5px;left:5px;box-sizing:border-box;width:calc(100% - 30px);margin:10px 15px;padding:7px 30px 7px 9px;border:1px solid #999;border-radius:3px}.selectr-notice{display:none;box-sizing:border-box;width:100%;padding:8px 16px;border-top:1px solid #999;border-radius:0 0 3px 3px;background-color:#fff}.selectr-container.notice .selectr-notice{display:block}.selectr-container.notice .selectr-selected{border-radius:3px 3px 0 0}.selectr-options{position:relative;top:calc(100% + 2px);display:none;overflow-x:auto;overflow-y:scroll;max-height:200px;margin:0;padding:0}.selectr-container.notice .selectr-options-container,.selectr-container.open .selectr-input-container,.selectr-container.open .selectr-options{display:block}.selectr-option{position:relative;display:block;padding:5px 20px;list-style:outside none none;cursor:pointer;font-weight:400}.selectr-options.optgroups>.selectr-option{padding-left:25px}.selectr-optgroup{font-weight:700;padding:0}.selectr-optgroup--label{font-weight:700;margin-top:10px;padding:5px 15px}.selectr-match{text-decoration:underline}.selectr-option.selected{background-color:#ddd}.selectr-option.active{color:#fff;background-color:#5897fb}.selectr-option.disabled{opacity:.4}.selectr-option.excluded{display:none}.selectr-container.open .selectr-selected{border-color:#999 #999 transparent #999;border-radius:3px 3px 0 0}.selectr-container.open .selectr-selected::after{-o-transform:rotate(180deg) translate3d(0,50%,0);-ms-transform:rotate(180deg) translate3d(0,50%,0);-moz-transform:rotate(180deg) translate3d(0,50%,0);-webkit-transform:rotate(180deg) translate3d(0,50%,0);transform:rotate(180deg) translate3d(0,50%,0)}.selectr-disabled{opacity:.6}.has-selected .selectr-placeholder,.selectr-empty{display:none}.has-selected .selectr-label{display:block}.taggable .selectr-selected{padding:4px 28px 4px 4px}.taggable .selectr-selected::after{display:table;content:" ";clear:both}.taggable .selectr-label{width:auto}.taggable .selectr-tags{float:left;display:block}.taggable .selectr-placeholder{display:none}.input-tag{float:left;min-width:90px;width:auto}.selectr-tag-input{border:medium none;padding:3px 10px;width:100%;font-family:inherit;font-weight:inherit;font-size:inherit}.selectr-input-container.loading::after{position:absolute;top:50%;right:20px;width:20px;height:20px;content:"";-o-transform:translate3d(0,-50%,0);-ms-transform:translate3d(0,-50%,0);-moz-transform:translate3d(0,-50%,0);-webkit-transform:translate3d(0,-50%,0);transform:translate3d(0,-50%,0);-o-transform-origin:50% 0 0;-ms-transform-origin:50% 0 0;-moz-transform-origin:50% 0 0;-webkit-transform-origin:50% 0 0;transform-origin:50% 0 0;-moz-animation:.5s linear 0s normal forwards infinite running selectr-spin;-webkit-animation:.5s linear 0s normal forwards infinite running selectr-spin;animation:.5s linear 0s normal forwards infinite running selectr-spin;border-width:3px;border-style:solid;border-color:#aaa #ddd #ddd;border-radius:50%}@-webkit-keyframes selectr-spin{0%{-webkit-transform:rotate(0) translate3d(0,-50%,0);transform:rotate(0) translate3d(0,-50%,0)}100%{-webkit-transform:rotate(360deg) translate3d(0,-50%,0);transform:rotate(360deg) translate3d(0,-50%,0)}}@keyframes selectr-spin{0%{-webkit-transform:rotate(0) translate3d(0,-50%,0);transform:rotate(0) translate3d(0,-50%,0)}100%{-webkit-transform:rotate(360deg) translate3d(0,-50%,0);transform:rotate(360deg) translate3d(0,-50%,0)}}.selectr-container.open.inverted .selectr-selected{border-color:transparent #999 #999;border-radius:0 0 3px 3px}.selectr-container.inverted .selectr-options-container{border-width:1px 1px 0;border-color:#999 #999 transparent;border-radius:3px 3px 0 0;background-color:#fff}.selectr-container.inverted .selectr-options-container{top:auto;bottom:calc(100% - 1px)}.selectr-container ::-webkit-input-placeholder{color:#6c7a86;opacity:1}.selectr-container ::-moz-placeholder{color:#6c7a86;opacity:1}.selectr-container :-ms-input-placeholder{color:#6c7a86;opacity:1}.selectr-container ::placeholder{color:#6c7a86;opacity:1}
|
|
7
7
|
|
|
8
8
|
/*Dark mode */
|
|
9
|
-
@media (prefers-color-scheme:dark){div.jsoneditor,div.jsoneditor-menu{border-color:#4b4b4b}div.jsoneditor-menu{background-color:#4b4b4b}div.jsoneditor textarea.jsoneditor-text,div.jsoneditor-tree{background-color:#666;color:#fff}div.jsoneditor-field,div.jsoneditor-value,div.jsoneditor-value.jsoneditor-invalid{color:#fff}table.jsoneditor-search div.jsoneditor-frame{background:grey}tr.jsoneditor-highlight,tr.jsoneditor-selected{background-color:grey}div.jsoneditor-field.jsoneditor-highlight,div.jsoneditor-field[contenteditable=true]:focus,div.jsoneditor-field[contenteditable=true]:hover,div.jsoneditor-value.jsoneditor-highlight,div.jsoneditor-value[contenteditable=true]:focus,div.jsoneditor-value[contenteditable=true]:hover{background-color:grey;border-color:grey}div.jsoneditor-field.highlight-active,div.jsoneditor-field.highlight-active:focus,div.jsoneditor-field.highlight-active:hover,div.jsoneditor-value.highlight-active,div.jsoneditor-value.highlight-active:focus,div.jsoneditor-value.highlight-active:hover{background-color:#b1b1b1;border-color:#b1b1b1}div.jsoneditor-tree button:focus{background-color:#868686}div.jsoneditor td.jsoneditor-separator,div.jsoneditor-readonly{color:#acacac}div.jsoneditor-value.jsoneditor-string{color:#0f8}div.jsoneditor-value.jsoneditor-array,div.jsoneditor-value.jsoneditor-object{color:#bababa}div.jsoneditor-value.jsoneditor-number{color:#ff4040}div.jsoneditor-value.jsoneditor-boolean{color:#ff8048}div.jsoneditor-value.jsoneditor-null{color:#49a7fc}input[type=text]{background-color:#
|
|
9
|
+
@media (prefers-color-scheme:dark){div.jsoneditor,div.jsoneditor-menu{border-color:#4b4b4b}div.jsoneditor-menu{background-color:#4b4b4b}div.jsoneditor textarea.jsoneditor-text,div.jsoneditor-tree{background-color:#666;color:#fff}div.jsoneditor-field,div.jsoneditor-value,div.jsoneditor-value.jsoneditor-invalid{color:#fff}table.jsoneditor-search div.jsoneditor-frame{background:grey}tr.jsoneditor-highlight,tr.jsoneditor-selected{background-color:grey}div.jsoneditor-field.jsoneditor-highlight,div.jsoneditor-field[contenteditable=true]:focus,div.jsoneditor-field[contenteditable=true]:hover,div.jsoneditor-value.jsoneditor-highlight,div.jsoneditor-value[contenteditable=true]:focus,div.jsoneditor-value[contenteditable=true]:hover{background-color:grey;border-color:grey}div.jsoneditor-field.highlight-active,div.jsoneditor-field.highlight-active:focus,div.jsoneditor-field.highlight-active:hover,div.jsoneditor-value.highlight-active,div.jsoneditor-value.highlight-active:focus,div.jsoneditor-value.highlight-active:hover{background-color:#b1b1b1;border-color:#b1b1b1}div.jsoneditor-tree button:focus{background-color:#868686}div.jsoneditor td.jsoneditor-separator,div.jsoneditor-readonly{color:#acacac}div.jsoneditor-value.jsoneditor-string{color:#0f8}div.jsoneditor-value.jsoneditor-array,div.jsoneditor-value.jsoneditor-object{color:#bababa}div.jsoneditor-value.jsoneditor-number{color:#ff4040}div.jsoneditor-value.jsoneditor-boolean{color:#ff8048}div.jsoneditor-value.jsoneditor-null{color:#49a7fc}input[type=text]{background-color:#121212;color:#ffffff}}
|
|
@@ -21,5 +21,9 @@
|
|
|
21
21
|
var content = document.getElementById("{{ widget.name }}_data").textContent;
|
|
22
22
|
textarea.value = content;
|
|
23
23
|
editor.set(JSON.parse(content));
|
|
24
|
+
|
|
25
|
+
// Expose editor instance for external access
|
|
26
|
+
window['{{ widget.attrs.id }}_editor'] = editor;
|
|
27
|
+
container.jsonEditor = editor;
|
|
24
28
|
})();
|
|
25
29
|
</script>
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import json
|
|
2
|
-
from builtins import super
|
|
3
2
|
|
|
4
3
|
from django import forms
|
|
5
4
|
from django.conf import settings
|
|
@@ -31,7 +30,7 @@ class JSONEditorWidget(forms.Widget):
|
|
|
31
30
|
self.width = width
|
|
32
31
|
self.height = height
|
|
33
32
|
|
|
34
|
-
super(
|
|
33
|
+
super().__init__(attrs=attrs)
|
|
35
34
|
|
|
36
35
|
def get_context(self, name, value, attrs):
|
|
37
36
|
context = super().get_context(name, value, attrs)
|
|
@@ -42,4 +41,7 @@ class JSONEditorWidget(forms.Widget):
|
|
|
42
41
|
return context
|
|
43
42
|
|
|
44
43
|
def format_value(self, value):
|
|
45
|
-
|
|
44
|
+
if not isinstance(value, (dict, list)):
|
|
45
|
+
return json.loads(value)
|
|
46
|
+
else:
|
|
47
|
+
return value
|