使用Django CKeditor,如何在不同的字段上加载不同的工具栏?

时间:2016-11-03 17:42:31

标签: django ckeditor django-ckeditor

我正在使用django CKeditor插件。我的配置如下:

CKEDITOR_CONFIGS = {
'default': {
    'skin': 'moono', #'office2013'
    'toolbar': 'Custom', #selects from below
    'toolbar_Custom': [
          ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript']
    ],
'toolbar_simple': {
    'skin': 'moono',
    'toolbar': 'Custom',
    'toolbar_Custom': [
         ['Bold', 'Italic', 'Underline'],
         ['NumberedList', 'BulletedList'],
    ],
},
'toolbar_basic':  {
    'toolbar': 'Basic'
},
'toolbar_full': {
    'toolbar': 'full',
},
}

我有时需要显示简单的工具栏,有时还会显示完整的工具栏。我怎么能这样做?

我希望有一个选项:

directions_car = RichTextField("Directions by car", max_length=1000, blank=False, default="", uses="toolbar_Custom")

1 个答案:

答案 0 :(得分:0)

您可以使用config_name属性设置不同的工具栏。

directions_car = RichTextField("Directions by car", max_length=1000, blank=False, default="", config_name="toolbar_Custom")

Reference

相关问题