0

我创建了一个博客并安装了 django-tinymce 1.5.2。但是当按照上述文档进行配置时,我没有在管理面板中输入文本的字段。

我的模型

class Post(models.Model):
    DRAFT = "D"
    PUBLISHED = "P"
    POST_STATUS = (
        (DRAFT, "Draft"),
        (PUBLISHED, "Published"),
    )
    title = models.CharField(max_length=120)
    text = HTMLField()
    status = models.CharField(choices=POST_STATUS, default=DRAFT, max_length=10)
    creation_date = models.DateTimeField(auto_now_add=True)
    modification_date = models.DateTimeField(auto_now=True)

设置.py

INSTALLED_APPS = (
    ....
    'suit',
    'tinymce',
    ....
)

TINYMCE_JS_URL = os.path.join(STATIC_URL, 'tinymce/js/tinymce/tinymce.min.js')
TINYMCE_JS_ROOT = '/static/js/tiny_mce'
TINYMCE_DEFAULT_CONFIG = {
    'plugins': "table,spellchecker,paste,searchreplace,print,textcolor",
    'theme': "modern",
    'cleanup_on_startup': True,
    'custom_undo_redo_levels': 10,
}
TINYMCE_SPELLCHECKER = True
TINYMCE_COMPRESSOR = True
4

1 回答 1

0

首先,我建议按照此处的说明测试所有内容是否已正确安装。我刚刚尝试过,一切正常,接受设置文件名为“testtinymce.settings”而不是“testtinymce.staticfiles_settings”。

您可以查看以下管理代码示例(/site-packages/testtinymce/testapp/admin.py)。

至于304 代码- 这只是意味着该文件已在本地缓存,不需要再次从服务器检索。

def formfield_for_dbfield(self, db_field, **kwargs):
        if db_field.name in ('content1', 'content2'):
            return db_field.formfield(widget=TinyMCE(
                attrs={'cols': 80, 'rows': 30},
                mce_attrs={'external_link_list_url': reverse('tinymce.views.flatpages_link_list')},
            ))
        return super(TinyMCETestInlineAdmin, self).formfield_for_dbfield(db_field, **kwargs)
于 2015-04-15T18:58:10.670 回答