带有 django 的 TinyMCE,编辑选项较少

TinyMCE with django, less options for editing

我刚刚安装了 TinyMCE 并将其配置到我的应用程序中。但是我在 TinyMCE 中看到的很少而且只有基本的编辑选项。没有上传图片甚至调整文本大小的选项。是我配置错了还是选项真的有限? 这是带有 TinyMCE 的文本字段的屏幕截图:

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

admin.py

from django.contrib import admin
from .models import blogpost
from django.db.models import TextField
from tinymce.widgets import TinyMCE
class EntryAdmin(MarkdownModelAdmin):
    list_display = ("title","publishdate")
    formfield_overrides = {TextField: {'widget': TinyMCE(attrs={'cols': 80, 'rows': 30})}}

admin.site.register(blogpost, EntryAdmin)

您可能想要更改 tinymce 配置的 "plugins" 和 "theme"。

来自文档 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