TinyMCE with Django,编辑选项更少

2024-04-19 08:11:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我刚刚安装了TinyMCE并将其配置到我的应用程序中。但我在TinyMCE中看到的编辑选项非常少,而且只有基本的编辑选项。没有选项可以上载图像,甚至无法调整文本的大小。是我配置错了还是它的选项真的有限? 下面是带有TinyMCE的textfield的屏幕截图: enter image description here

在模型.py在

from __future__ import unicode_literals
from django.template.defaultfilters import slugify
from django.contrib.auth.models import User
from tinymce.models import HTMLField
from django.db import models
from datetime import datetime
class blogpost(models.Model):
    title = models.CharField(max_length = 200)
    body = models.TextField()
    publishdate = models.DateTimeField(default=datetime.now())

    def __unicode__(self):
        return self.title

在管理员py在

^{pr2}$

Tags: djangofrompy图像文本importself应用程序
1条回答
网友
1楼 · 发布于 2024-04-19 08:11:33

您可能需要更改tinymce配置的“插件”和“主题”。在

从文档https://django-tinymce.readthedocs.org/en/latest/installation.html#configuration

Configuration

The application can be configured by editing the project’s settings.py file.

TINYMCE_JS_URL (default: settings.MEDIA_URL + 'js/tiny_mce/tiny_mce.js')

The URL of the TinyMCE javascript file:

TINYMCE_JS_URL = os.path.join(MEDIA_URL, "path/to/tiny_mce/tiny_mce.js")

TINYMCE_JS_ROOT (default: settings.MEDIA_ROOT + 'js/tiny_mce')

The filesystem location of the TinyMCE files. It is used by the compressor (see below):

TINYMCE_JS_ROOT = os.path.join(MEDIA_ROOT, "path/to/tiny_mce")

TINYMCE_DEFAULT_CONFIG (default: {'theme': "simple", 'relative_urls': False}) The default TinyMCE configuration to use. See the TinyMCE manual for all options. To set the configuration for a specific TinyMCE editor, see the mce_attrs parameter for the widget. TINYMCE_SPELLCHECKER (default: False) Whether to use the spell checker through the supplied view. You must add spellchecker to the TinyMCE plugin list yourself, it is not added automatically. TINYMCE_COMPRESSOR (default: False) Whether to use the TinyMCE compressor, which gzips all Javascript files into a single stream. This makes the overall download size 75% smaller and also reduces the number of requests. The overall initialization time for TinyMCE will be reduced dramatically if you use this option. TINYMCE_FILEBROWSER (default: True if 'filebrowser' is in INSTALLED_APPS, else False) Whether to use the django-filebrowser as a custom filebrowser for media inclusion. See the official TinyMCE documentation on custom filebrowsers.

Example:

TINYMCE_JS_URL = 'http://debug.example.org/tiny_mce/tiny_mce_src.js'

TINYMCE_DEFAULT_CONFIG = {
        'plugins': "table,spellchecker,paste,searchreplace",
        'theme': "advanced",
        'cleanup_on_startup': True,
        'custom_undo_redo_levels': 10, }  TINYMCE_SPELLCHECKER = True

TINYMCE_COMPRESSOR = True

相关问题 更多 >