diff options
author | CoprDistGit <infra@openeuler.org> | 2023-06-20 04:53:22 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-06-20 04:53:22 +0000 |
commit | 4e065e18c9ea276ab6eafd336e5367b318ced1da (patch) | |
tree | 3f5a98d9ceba388b39b7d0ddbcf570c52e1652f8 /python-django-jsoneditor-widget.spec | |
parent | 0709229f0b24876c77d0cc67d08fa9968d01d807 (diff) |
automatic import of python-django-jsoneditor-widgetopeneuler20.03
Diffstat (limited to 'python-django-jsoneditor-widget.spec')
-rw-r--r-- | python-django-jsoneditor-widget.spec | 342 |
1 files changed, 342 insertions, 0 deletions
diff --git a/python-django-jsoneditor-widget.spec b/python-django-jsoneditor-widget.spec new file mode 100644 index 0000000..c621a8e --- /dev/null +++ b/python-django-jsoneditor-widget.spec @@ -0,0 +1,342 @@ +%global _empty_manifest_terminate_build 0 +Name: python-django-jsoneditor-widget +Version: 1.3.2 +Release: 1 +Summary: Django form widget form JSONField +License: MIT +URL: https://github.com/arthurc0102/django-jsoneditor-widget +Source0: https://mirrors.aliyun.com/pypi/web/packages/e2/cd/d6784514c329bf96bc322304b173de071ae0f52070a588ce6e1832369dfd/django-jsoneditor-widget-1.3.2.tar.gz +BuildArch: noarch + + +%description +# django-jsoneditor-widget + +> Django form widget form JSONField + +## Demo + +It look like this. + + + +## Install + +- Install: `pip install django-jsoneditor-widget` +- Settings: + ```python + INSTALLED_APPS = [ + # some apps .... + 'jsoneditor', + # other apps ... + ] + ``` + +## Create model + +```python +from django.db import models +from django.contrib.postgres.fields import JSONField + + +class Book(models.Model): + name = models.CharField(max_length=150) + information = JSONField() + + def __str__(self): + return self.name +``` + +## Admin site settings + +- Use ModelAdmin + ```python + from django.contrib import admin + + from jsoneditor.admin import JSONFieldModelAdmin + + from .models import Book + + + admin.site.register(Product, JSONFieldModelAdmin) + ``` + +- Use mixin + ```python + from django.contrib import admin + + from jsoneditor.admin import JSONFieldAdminMixin + + from .models import Book + + + @admin.register(Book) + class BookModelAdmin(JSONFieldAdminMixin, admin.ModelAdmin): + pass + ``` + +- Use custom widget to specify jsoneditor options + ```python + from django.contrib import admin + from django.contrib.postgres.fields import JSONField + + from jsoneditor.forms import JSONEditor + + from .models import Book + + + class TextJSONEditor(JSONEditor): + jsoneditor_options = { + "mode": "text" + } + + + @admin.register(Book) + class BookModelAdmin(admin.ModelAdmin): + formfield_overrides = { + JSONField: {"widget": TextJSONEditor} + } + + ``` + + + + +%package -n python3-django-jsoneditor-widget +Summary: Django form widget form JSONField +Provides: python-django-jsoneditor-widget +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-django-jsoneditor-widget +# django-jsoneditor-widget + +> Django form widget form JSONField + +## Demo + +It look like this. + + + +## Install + +- Install: `pip install django-jsoneditor-widget` +- Settings: + ```python + INSTALLED_APPS = [ + # some apps .... + 'jsoneditor', + # other apps ... + ] + ``` + +## Create model + +```python +from django.db import models +from django.contrib.postgres.fields import JSONField + + +class Book(models.Model): + name = models.CharField(max_length=150) + information = JSONField() + + def __str__(self): + return self.name +``` + +## Admin site settings + +- Use ModelAdmin + ```python + from django.contrib import admin + + from jsoneditor.admin import JSONFieldModelAdmin + + from .models import Book + + + admin.site.register(Product, JSONFieldModelAdmin) + ``` + +- Use mixin + ```python + from django.contrib import admin + + from jsoneditor.admin import JSONFieldAdminMixin + + from .models import Book + + + @admin.register(Book) + class BookModelAdmin(JSONFieldAdminMixin, admin.ModelAdmin): + pass + ``` + +- Use custom widget to specify jsoneditor options + ```python + from django.contrib import admin + from django.contrib.postgres.fields import JSONField + + from jsoneditor.forms import JSONEditor + + from .models import Book + + + class TextJSONEditor(JSONEditor): + jsoneditor_options = { + "mode": "text" + } + + + @admin.register(Book) + class BookModelAdmin(admin.ModelAdmin): + formfield_overrides = { + JSONField: {"widget": TextJSONEditor} + } + + ``` + + + + +%package help +Summary: Development documents and examples for django-jsoneditor-widget +Provides: python3-django-jsoneditor-widget-doc +%description help +# django-jsoneditor-widget + +> Django form widget form JSONField + +## Demo + +It look like this. + + + +## Install + +- Install: `pip install django-jsoneditor-widget` +- Settings: + ```python + INSTALLED_APPS = [ + # some apps .... + 'jsoneditor', + # other apps ... + ] + ``` + +## Create model + +```python +from django.db import models +from django.contrib.postgres.fields import JSONField + + +class Book(models.Model): + name = models.CharField(max_length=150) + information = JSONField() + + def __str__(self): + return self.name +``` + +## Admin site settings + +- Use ModelAdmin + ```python + from django.contrib import admin + + from jsoneditor.admin import JSONFieldModelAdmin + + from .models import Book + + + admin.site.register(Product, JSONFieldModelAdmin) + ``` + +- Use mixin + ```python + from django.contrib import admin + + from jsoneditor.admin import JSONFieldAdminMixin + + from .models import Book + + + @admin.register(Book) + class BookModelAdmin(JSONFieldAdminMixin, admin.ModelAdmin): + pass + ``` + +- Use custom widget to specify jsoneditor options + ```python + from django.contrib import admin + from django.contrib.postgres.fields import JSONField + + from jsoneditor.forms import JSONEditor + + from .models import Book + + + class TextJSONEditor(JSONEditor): + jsoneditor_options = { + "mode": "text" + } + + + @admin.register(Book) + class BookModelAdmin(admin.ModelAdmin): + formfield_overrides = { + JSONField: {"widget": TextJSONEditor} + } + + ``` + + + + +%prep +%autosetup -n django-jsoneditor-widget-1.3.2 + +%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-jsoneditor-widget -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Tue Jun 20 2023 Python_Bot <Python_Bot@openeuler.org> - 1.3.2-1 +- Package Spec generated |