django-tinymce 1.5.2无字段输入文字

时间:2015-04-15 15:40:44

标签: python django tinymce django-tinymce

我创建了一个博客并安装了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)

settings.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

1 个答案:

答案 0 :(得分:0)

首先,我建议按照here说明测试所有内容是否正确安装。我只是尝试了它,一切正常,接受设置文件被命名为“testtinymce.settings”而不是“testtinymce.staticfiles_settings。”

您可以看到管理员代码的示例,如下所示(/site-packages/testtinymce/testapp/admin.py)。

至于304 code - 这意味着文件已在本地缓存,无需再次从服务器检索。

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)