用于将页面生成器“grapesjs”集成到django管理中的小型库

django-grapesjs的Python项目详细描述


django_图形js

Maintainabilitycontributions welcomeHitCount

一个小型库允许您将页面生成器“grapesjs”集成到django admin中

安装

pip install django_grapesjs

然后将其添加到已安装的应用程序中:

INSTALLED_APPS=('django_grapesjs',...'django.contrib.admin',)

要使用“template_choices”,需要在urls.py文件中添加一个url模板

urlpatterns=[path('get_template/',GetTemplate.as_view(),name='dgjs_get_template'),]

使用

只需导入字段并将其添加到模型中即可

fromdjango.dbimportmodelsfromdjango_grapesjs.modelsimportGrapesJsHtmlFieldclassExampleModel(models.Model):html=GrapesJsHtmlField()...# default_html - path to the html file to display the default value# for the field when the form page is receivedhtml=GrapesJsHtmlField(default_html='default.html')# or default - if the page is simply statichtml=GrapesJsHtmlField(default=render_to_string('default.html'))...# use the redactor_config argument to select the configuration of the editor# Available:#     - redactor_config='base' - basic setting, most widgets are used#     - redactor_config='min' - minimum setting, only the most necessaryhtml=GrapesJsHtmlField(redactor_config='base')...# use apply_django_tag = True, if you want to apply render django or jinja tagshtml=GrapesJsHtmlField(default_html='default.html',apply_django_tag=True)...# use template_choices to select multiple templateshtml=GrapesJsHtmlField(template_choices=(('django_grapesjs/default.html','default'),))

然后继承当前模型

的管理类中的“pULSeJSADMIN MIXIN”
fromdjango.contribimportadminfromdjango_grapesjs.adminimportGrapesJsAdminMixin@admin.register(ExampleModel)classExampleAdmin(GrapesJsAdminMixin,admin.ModelAdmin):pass

您可以在模板中使用特殊标记,用于灵活定制

<ignore></ignore>

如果在保存过程中需要注释掉一些html代码, 但在页面生成器中编辑时执行或显示-使用此标记。 例如,如果使用django或jinja标记的模板没有任何样式或javascript (因为它们在另一个地方,例如在“footer.html”中),您可以将css和js放在 编辑器中的标记、样式和javascript代码将起作用,但在网站上保存和使用时 不会重复片段

<hidden></hidden>

如果在编辑器中使用apply_django_标记进行编辑,您可能会被附加的: {%exclude%}、{%include%}、{%for<;expression>;%}等-使用此标记。他暂时躲藏起来 在编辑和保存过程中嵌入的信息将返回到原始表单

自定义设置

# True if you want to save html and cssGRAPESJS_SAVE_CSS=False# default value# use the value of the field from the db - True, or use the global save editorGRAPESJS_DEFAULT_MODELS_DATA=True# default value# redefine the path to the html file, the markup from this file will be used by defaultGRAPESJS_DEFAULT_HTML='django_grapesjs/default.html'# default value# Add or redefine the configuration of the editorREDACTOR_CONFIG={'base':'django_grapesjs/redactor_config/base.html'}# default value

警告

库不能在“inlines”中工作

参考

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Java重写   java有一种制作jre1的方法。8作为jre1运行。7.   java从Android应用程序向AWS S3上传文件   java是一种正确的匿名子类化TimerTask的方法,在run方法中保留对“this”的引用   c#应用程序开发:我应该检查表上的primarykey还是假设它应该在那里?   swing在Java中绘制二叉树如何调用函数   网络编程在Java中通过按钮终止服务器程序   mysql从java创建SQL函数导致异常   java文件系统找不到指定的路径   JavaSpring安全性可用于GET,但不能用于其他方法   带有PDFBox的java标记PDF   Java swing,JButton在第一次按下按钮时不会调整大小,但在第二次按下按钮时会调整大小   java是我的PropertyLoader单例线程安全吗?   java如何在kafka consumer中按内容设置主题?   java优化jtable   从java包创建可执行jar文件   getLastKnownLocation()上的java Android应用程序崩溃   java RestTemplate:如何发送多部分?   JavaDropWizard:从同一个类生成html和json