用于将页面生成器“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中以相同的方式洗牌两个列表?   java如何使用WebFilter实现授权头检查   如何使用Java正确显示谷歌云存储中的日文字符?   使用Smook和Freemarker将Java对象转换为XML的模型是什么?   使用hibernate工具(Jboss)社区生成hibernate映射文件时发生java错误   java Android在运行任务时更新UI?   单元测试Powermockito/Java间谍类以验证私有方法调用   java libgdx在另一个上渲染srite会导致背景精灵消失   web服务如何在Java中创建这样的SOAP请求?   java文本视图把阿拉伯语字母弄乱了   java中的socket不活动超时   java Android Studio“未找到Android API平台30的源代码”   java Spring引导返回嵌套数组,但是。。。我需要数据,但只需要一次   java订阅doOnNext方法中的另一个可观察对象