Package: django-editor-widgets
Django-editor-widgetsThis package provides some custom widgets to use monaco or tinymce editors in django admin.remark: From version 4.0 static files for tinymce and monaco editors are removed.InstallationTo install the package bypiprun following command# From Github (latest updates)$pipinstallgit+https://github.com/giorgi94/django-editor-widgets.git# Or$pipinstalldjango-editor-widgetsUsageTo start using the package in your project, you need to opensettings.pyfile and add following lines# settings.pyfrompathlibimportPath# import configurations for editorfromdjangoeditorwidgets.configimportinit_web_editor_config# set base dir by Path instead of os.pathBASE_DIR=Path(__file__).resolve().parent.parent# Application definitionINSTALLED_APPS=[...'djangoeditorwidgets',...]MEDIA_URL="/media/"MEDIA_ROOT=BASE_DIR/"media"STATIC_URL="/static/"STATIC_ROOT=BASE_DIR/"static"WEB_EDITOR_DOWNLOAD,WEB_EDITOR_CONFIG=init_web_editor_config(# set the directory where files are downloadedBASE_DIR/"static_cdn",# set static url prefixSTATIC_URL)In current version usesPathinstead ofos.pathto manage files and directories. If needed configuration parameters can be written manuallyfromos.pathimportjoinWEB_EDITOR_DOWNLOAD={"to":BASE_DIR/"static_cdn","tinymce":{"url":"https://download.tiny.cloud/tinymce/community/tinymce_5.10.3.zip","target":"tinymce/js/tinymce",},"monaco":{"url":"https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.32.1.tgz","target":"package/min",},}WEB_EDITOR_CONFIG={"tinymce":{"js":[join(STATIC_URL,"tinymce/tinymce.min.js"),join(STATIC_URL,"djangoeditorwidgets/tinymce/tinymce.config.js"),join(STATIC_URL,"djangoeditorwidgets/tinymce/tinymce.init.js"),],"css":{"all":[join(STATIC_URL,"djangoeditorwidgets/tinymce/tinymce.custom.css"),]},},"monaco":{"js":[join(STATIC_URL,"monaco/vs/loader.js"),join(STATIC_URL,"djangoeditorwidgets/monaco/monaco.config.js"),],"css":{"all":[join(STATIC_URL,"djangoeditorwidgets/monaco/monaco.custom.css"),]},},}CommandsStatic files are removed from the package, instead it provides management command to download and extract files to given  location$pythonmanage.pydownload_editpr_scriptsTinyMCETo use tinymce editor in admin, we need to change default widget in the form withTinymceWidget# forms.pyfromdjangoimportformsfromdjangoeditorwidgets.widgetsimportTinymceWidgetfrom.modelsimportTextModelclassTextModelForm(forms.ModelForm):classMeta:model=TextModelfields='__all__'widgets={'text':TinymceWidget(name="default")}Bynameargument we can modify selector and can define multiple configs for tinymce editor.Monaco EditorIn lastest verions ofsqlite3andmariadbwe now havejson field, it is more limited compared topostgresqlbut can handle json validation and parsing# models.pyimportjsonfromdjango.dbimportmodelsclassJSONModel(models.Model):title=models.CharField(max_length=50)text=models.JSONField(null=True)def__str__(self):returnself.title# forms.pyfromdjangoimportformsfromdjangoeditorwidgets.widgetsimportMonacoEditorWidgetfrom.modelsimportJSONModelclassJsonModelForm(forms.ModelForm):classMeta:model=JSONModelfields="__all__"widgets={"text":MonacoEditorWidget(name="default",language="json",wordwrap=True)}RemarkUnlike 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.