{"id":22547017,"url":"https://github.com/giorgi94/django-editor-widgets","last_synced_at":"2025-05-11T15:43:34.558Z","repository":{"id":57419885,"uuid":"157204850","full_name":"giorgi94/django-editor-widgets","owner":"giorgi94","description":"This package provides some custom widgets to use monaco or tinymce editors in django admin.","archived":false,"fork":false,"pushed_at":"2025-03-08T07:17:22.000Z","size":4198,"stargazers_count":16,"open_issues_count":1,"forks_count":12,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-05T01:12:41.973Z","etag":null,"topics":["django","json","monaco-editor","tinymce","xml"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/giorgi94.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-12T11:42:39.000Z","updated_at":"2025-03-08T07:17:20.000Z","dependencies_parsed_at":"2024-06-21T16:42:37.618Z","dependency_job_id":"a6a3120c-f39c-4b68-95eb-b2e0ba24f4be","html_url":"https://github.com/giorgi94/django-editor-widgets","commit_stats":{"total_commits":34,"total_committers":2,"mean_commits":17.0,"dds":0.02941176470588236,"last_synced_commit":"3eef003314b4fa55dcd2bc170a14a779108873a7"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giorgi94%2Fdjango-editor-widgets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giorgi94%2Fdjango-editor-widgets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giorgi94%2Fdjango-editor-widgets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/giorgi94%2Fdjango-editor-widgets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/giorgi94","download_url":"https://codeload.github.com/giorgi94/django-editor-widgets/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253436885,"owners_count":21908423,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","json","monaco-editor","tinymce","xml"],"created_at":"2024-12-07T15:09:46.065Z","updated_at":"2025-05-10T15:32:53.761Z","avatar_url":"https://github.com/giorgi94.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Django-editor-widgets\n\n\nThis package provides some custom widgets to use monaco or tinymce editors in django admin.\n\n**remark**: From version 4.0 static files for tinymce and monaco editors are removed.\n\n\n## Installation\n\nTo install the package by `pip` run following command\n\n```sh\n# From Github (latest updates)\n$ pip install git+https://github.com/giorgi94/django-editor-widgets.git\n# Or\n$ pip install django-editor-widgets\n```\n\n## Usage\n\nTo start using the package in your project, you need to open `settings.py` file and add following lines\n\n```python\n# settings.py\nfrom pathlib import Path\n\n# import configurations for editor\nfrom djangoeditorwidgets.config import init_web_editor_config\n\n# set base dir by Path instead of os.path\nBASE_DIR = Path(__file__).resolve().parent.parent\n\n# Application definition\n\nINSTALLED_APPS = [\n    ...\n    'djangoeditorwidgets',\n    ...\n]\n\n\nMEDIA_URL = \"/media/\"\nMEDIA_ROOT = BASE_DIR / \"media\"\n\nSTATIC_URL = \"/static/\"\nSTATIC_ROOT = BASE_DIR / \"static\"\n\nWEB_EDITOR_DOWNLOAD, WEB_EDITOR_CONFIG = init_web_editor_config(\n    # set the directory where files are downloaded\n    BASE_DIR / \"static_cdn\",\n    # set static url prefix\n    STATIC_URL\n)\n\n\n```\n\nIn current version uses `Path` instead of `os.path` to manage files and directories. If needed configuration parameters can be written manually\n\n```python\nfrom os.path import join\n\nWEB_EDITOR_DOWNLOAD = {\n    \"to\": BASE_DIR / \"static_cdn\",\n    \"tinymce\": {\n        \"url\": \"https://download.tiny.cloud/tinymce/community/tinymce_5.10.3.zip\",\n        \"target\": \"tinymce/js/tinymce\",\n    },\n    \"monaco\": {\n        \"url\": \"https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.32.1.tgz\",\n        \"target\": \"package/min\",\n    },\n}\n\nWEB_EDITOR_CONFIG = {\n    \"tinymce\": {\n        \"js\": [\n            join(STATIC_URL, \"tinymce/tinymce.min.js\"),\n            join(STATIC_URL, \"djangoeditorwidgets/tinymce/tinymce.config.js\"),\n            join(STATIC_URL, \"djangoeditorwidgets/tinymce/tinymce.init.js\"),\n        ],\n        \"css\": {\n            \"all\": [\n                join(STATIC_URL, \"djangoeditorwidgets/tinymce/tinymce.custom.css\"),\n            ]\n        },\n    },\n    \"monaco\": {\n        \"js\": [\n            join(STATIC_URL, \"monaco/vs/loader.js\"),\n            join(STATIC_URL, \"djangoeditorwidgets/monaco/monaco.config.js\"),\n        ],\n        \"css\": {\n            \"all\": [\n                join(STATIC_URL, \"djangoeditorwidgets/monaco/monaco.custom.css\"),\n            ]\n        },\n    },\n}\n```\n\n\n### Commands\n\nStatic files are removed from the package, instead it provides management command to download and extract files to given  location\n\n```bash\n$ python manage.py download_editor_scripts\n```\n\n\n### TinyMCE\n\nTo use tinymce editor in admin, we need to change default widget in the form with `TinymceWidget`\n\n\n```python\n# forms.py\nfrom django import forms\nfrom djangoeditorwidgets.widgets import TinymceWidget\nfrom .models import TextModel\n\n\nclass TextModelForm(forms.ModelForm):\n\n    class Meta:\n        model = TextModel\n        fields = '__all__'\n        widgets = {\n            'text': TinymceWidget(name=\"default\")\n        }\n```\n\nBy `name` argument we can modify selector and can define multiple configs for tinymce editor.\n\n\n### Monaco Editor\n\nIn lastest verions of `sqlite3` and `mariadb` we now have `json field`, it is more limited compared to `postgresql` but can handle json validation and parsing\n\n```python\n# models.py\nimport json\nfrom django.db import models\n\nclass JSONModel(models.Model):\n    title = models.CharField(max_length=50)\n    text = models.JSONField(null=True)\n\n    def __str__(self):\n        return self.title\n\n\n# forms.py\nfrom django import forms\nfrom djangoeditorwidgets.widgets import MonacoEditorWidget\nfrom .models import JSONModel\n\n\nclass JsonModelForm(forms.ModelForm):\n    class Meta:\n        model = JSONModel\n        fields = \"__all__\"\n        widgets = {\n            \"text\": MonacoEditorWidget(name=\"default\", language=\"json\", wordwrap=True)\n        }\n\n```\n\n## Remark\n\nUnlike other django package which are for Rich web editors, this package allows developer to fully use capablities and custom plugins for the web editor, like tinymce or monaco, since configurations doesn't go through django settings.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiorgi94%2Fdjango-editor-widgets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgiorgi94%2Fdjango-editor-widgets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgiorgi94%2Fdjango-editor-widgets/lists"}