%global _empty_manifest_terminate_build 0 Name: python-django-admin-json-editor Version: 0.2.3 Release: 1 Summary: A simple Django app to add JSON widget into Django Administration. License: MIT License URL: https://github.com/abogushov/django-admin-json-editor Source0: https://mirrors.nju.edu.cn/pypi/web/packages/db/eb/33401a7c47b078b12a281952c6e963906602a3eeff13f400adda15e4de7f/django-admin-json-editor-0.2.3.tar.gz BuildArch: noarch %description # Django Administration JSON Editor [![Build Status](https://travis-ci.org/abogushov/django-admin-json-editor.svg?branch=master)](https://travis-ci.org/abogushov/django-admin-json-editor) ![Admin Json Editor](example/example.png) Application adds support for editing JSONField in Django Administration via https://github.com/json-editor/json-editor. ## Quick start Install application via pip: ```bash pip install django-admin-json-editor ``` Add application to the INSTALLED_APPS settings: ```python INSTALLED_APPS = [ ... 'django_admin_json_editor', ... ] ``` Define schema of json field: ```python DATA_SCHEMA = { 'type': 'object', 'title': 'Data', 'properties': { 'text': { 'title': 'Some text', 'type': 'string', 'format': 'textarea', }, 'status': { 'title': 'Status', 'type': 'boolean', }, }, } ``` Use JSONEditorWidget to bind editor to the form field: ```python class JSONModelAdminForm(forms.ModelForm): class Meta: model = JSONModel fields = '__all__' widgets = { 'data': JSONEditorWidget(DATA_SCHEMA, collapsed=False), } ``` ### Dynamic schema It is possible to build dynamic schema for widget: ```python def dynamic_schema(widget): return { 'type': 'array', 'title': 'tags', 'items': { 'type': 'string', 'enum': [i for i in Tag.objects.values_list('name', flat=True)], } } ``` ```python @admin.register(JSONModel) class JSONModelAdmin(admin.ModelAdmin): def get_form(self, request, obj=None, **kwargs): widget = JSONEditorWidget(dynamic_schema, False) form = super().get_form(request, obj, widgets={'tags': widget}, **kwargs) return form ``` %package -n python3-django-admin-json-editor Summary: A simple Django app to add JSON widget into Django Administration. Provides: python-django-admin-json-editor BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-django-admin-json-editor # Django Administration JSON Editor [![Build Status](https://travis-ci.org/abogushov/django-admin-json-editor.svg?branch=master)](https://travis-ci.org/abogushov/django-admin-json-editor) ![Admin Json Editor](example/example.png) Application adds support for editing JSONField in Django Administration via https://github.com/json-editor/json-editor. ## Quick start Install application via pip: ```bash pip install django-admin-json-editor ``` Add application to the INSTALLED_APPS settings: ```python INSTALLED_APPS = [ ... 'django_admin_json_editor', ... ] ``` Define schema of json field: ```python DATA_SCHEMA = { 'type': 'object', 'title': 'Data', 'properties': { 'text': { 'title': 'Some text', 'type': 'string', 'format': 'textarea', }, 'status': { 'title': 'Status', 'type': 'boolean', }, }, } ``` Use JSONEditorWidget to bind editor to the form field: ```python class JSONModelAdminForm(forms.ModelForm): class Meta: model = JSONModel fields = '__all__' widgets = { 'data': JSONEditorWidget(DATA_SCHEMA, collapsed=False), } ``` ### Dynamic schema It is possible to build dynamic schema for widget: ```python def dynamic_schema(widget): return { 'type': 'array', 'title': 'tags', 'items': { 'type': 'string', 'enum': [i for i in Tag.objects.values_list('name', flat=True)], } } ``` ```python @admin.register(JSONModel) class JSONModelAdmin(admin.ModelAdmin): def get_form(self, request, obj=None, **kwargs): widget = JSONEditorWidget(dynamic_schema, False) form = super().get_form(request, obj, widgets={'tags': widget}, **kwargs) return form ``` %package help Summary: Development documents and examples for django-admin-json-editor Provides: python3-django-admin-json-editor-doc %description help # Django Administration JSON Editor [![Build Status](https://travis-ci.org/abogushov/django-admin-json-editor.svg?branch=master)](https://travis-ci.org/abogushov/django-admin-json-editor) ![Admin Json Editor](example/example.png) Application adds support for editing JSONField in Django Administration via https://github.com/json-editor/json-editor. ## Quick start Install application via pip: ```bash pip install django-admin-json-editor ``` Add application to the INSTALLED_APPS settings: ```python INSTALLED_APPS = [ ... 'django_admin_json_editor', ... ] ``` Define schema of json field: ```python DATA_SCHEMA = { 'type': 'object', 'title': 'Data', 'properties': { 'text': { 'title': 'Some text', 'type': 'string', 'format': 'textarea', }, 'status': { 'title': 'Status', 'type': 'boolean', }, }, } ``` Use JSONEditorWidget to bind editor to the form field: ```python class JSONModelAdminForm(forms.ModelForm): class Meta: model = JSONModel fields = '__all__' widgets = { 'data': JSONEditorWidget(DATA_SCHEMA, collapsed=False), } ``` ### Dynamic schema It is possible to build dynamic schema for widget: ```python def dynamic_schema(widget): return { 'type': 'array', 'title': 'tags', 'items': { 'type': 'string', 'enum': [i for i in Tag.objects.values_list('name', flat=True)], } } ``` ```python @admin.register(JSONModel) class JSONModelAdmin(admin.ModelAdmin): def get_form(self, request, obj=None, **kwargs): widget = JSONEditorWidget(dynamic_schema, False) form = super().get_form(request, obj, widgets={'tags': widget}, **kwargs) return form ``` %prep %autosetup -n django-admin-json-editor-0.2.3 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-django-admin-json-editor -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Tue Apr 11 2023 Python_Bot - 0.2.3-1 - Package Spec generated