Skip to content

Commit 2adc011

Browse files
committed
Initial
1 parent 64c7d08 commit 2adc011

25 files changed

+4012
-1
lines changed

.gitignore

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
5+
# C extensions
6+
*.so
7+
8+
# Distribution / packaging
9+
.Python
10+
env/
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
*.egg-info/
23+
.installed.cfg
24+
*.egg
25+
26+
# PyInstaller
27+
# Usually these files are written by a python script from a template
28+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
29+
*.manifest
30+
*.spec
31+
32+
# Installer logs
33+
pip-log.txt
34+
pip-delete-this-directory.txt
35+
36+
# Unit test / coverage reports
37+
htmlcov/
38+
.tox/
39+
.coverage
40+
.coverage.*
41+
.cache
42+
nosetests.xml
43+
coverage.xml
44+
*,cover
45+
46+
# Translations
47+
*.mo
48+
*.pot
49+
50+
# Django stuff:
51+
*.log
52+
53+
# Sphinx documentation
54+
docs/_build/
55+
56+
# PyBuilder
57+
target/

MANIFEST.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include LICENSE
2+
include README.rst
3+
recursive-include json_editor/static *
4+
recursive-include json_editor/templates *

README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
=================================
2+
Django Administration JSON Editor
3+
=================================
4+
5+
Application adds support for editing JSONField in Django Administration via https://github.com/jdorn/json-editor.
6+
7+
Quick start
8+
-----------
9+
10+
Add application to your INSTALLED_APPS setting like this ::
11+
12+
.. code-block:: python
13+
INSTALLED_APPS = [
14+
...
15+
'json_editor',
16+
]

json_editor/__init__.py

Whitespace-only changes.

json_editor/admin.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import json
2+
3+
from django import forms
4+
from django.utils.safestring import mark_safe
5+
from django.template.loader import render_to_string
6+
7+
8+
class JSONEditorWidget(forms.Widget):
9+
10+
template_name = 'django_json_editor/django_json_editor.html'
11+
12+
def __init__(self, schema):
13+
super().__init__()
14+
self._schema = schema
15+
16+
def render(self, name, value, attrs=None):
17+
self._schema['title'] = name
18+
context = {
19+
'name': name,
20+
'schema': self._schema,
21+
'data': json.loads(value),
22+
}
23+
return mark_safe(render_to_string(self.template_name, context))
24+
25+
class Media:
26+
css = {'all': (
27+
'django_json_editor/bootstrap/css/bootstrap.min.css',
28+
'django_json_editor/fontawesome/css/font-awesome.min.css',
29+
'django_json_editor/style.css',
30+
)}
31+
js = (
32+
'django_json_editor/jquery/jquery.min.js',
33+
'django_json_editor/bootstrap/js/bootstrap.min.js',
34+
'django_json_editor/jsoneditor/jsoneditor.min.js',
35+
)

json_editor/static/django_json_editor/bootstrap/css/bootstrap.min.css

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
19.7 KB
Binary file not shown.

json_editor/static/django_json_editor/bootstrap/fonts/glyphicons-halflings-regular.svg

Lines changed: 288 additions & 0 deletions
Loading
44.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)