django tiny mce 是普通文本字段而不是富文本格式吗?请修复。包括设置

发布于 2024-09-19 11:17:36 字数 1375 浏览 4 评论 0原文

我安装了 Django tiny mce,但是我在管理员中得到了一个普通的文本区域。任何人都可以帮助我将其更正为可以访问文本格式的富文本区域吗?

这是我的设置.py

 import os
PROJECT_DIR = os.path.dirname(__file__)

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', '[email protected]'),
)

MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': '',                      # Or path to database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}



...
...
...
...    
...    
...    
...    
...    
...    
...    
...    
...    
...    
...
TINYMCE_JS_URL = '/media/js/tiny_mce/tiny_mce.js/'

# languages you want to translate into the CMS.

DEFAULT_PAGE_TEMPLATE = 'pages/generic.html'

PAGE_TEMPLATES = (
    ('pages/generic.html', 'Generic'),
 ('pages/index.html', 'Home Page'),
    ('pages/people.html', 'People'),

)

I installed Django tiny mce however i am getting a normal text area in my admin. Can anyone help me to correct this to a rich text area where i can acces text formating?

here are my settings.py

 import os
PROJECT_DIR = os.path.dirname(__file__)

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', '[email protected]'),
)

MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': '',                      # Or path to database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}



...
...
...
...    
...    
...    
...    
...    
...    
...    
...    
...    
...    
...
TINYMCE_JS_URL = '/media/js/tiny_mce/tiny_mce.js/'

# languages you want to translate into the CMS.

DEFAULT_PAGE_TEMPLATE = 'pages/generic.html'

PAGE_TEMPLATES = (
    ('pages/generic.html', 'Generic'),
 ('pages/index.html', 'Home Page'),
    ('pages/people.html', 'People'),

)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

伴我心暖 2024-09-26 11:17:36

django-tinymce 不会用 TinyMCE 编辑器替换所有文本区域字段,您必须在模型中使用 HTMLField 明确使用它:

from django.db import models
from tinymce import models as tinymce_models

class MyModel(models.Model):
    my_field = tinymce_models.HTMLField()

或者对于第三方应用程序,通过替换管理中的小部件,如中所述文档

django-tinymce doesn't replace all textarea fields with TinyMCE editors, you have to use it explicitely either with HTMLField in your models:

from django.db import models
from tinymce import models as tinymce_models

class MyModel(models.Model):
    my_field = tinymce_models.HTMLField()

Or for third party apps by replacing the widgets in the admin, as explained in the documentation.

|煩躁 2024-09-26 11:17:36

使用这个..我前几天发现它,它是一个非常好的在 django 管理中使用tinymce的分步教程

http://code.djangoproject.com/wiki/AddWYSIWYGEditor

use this.. i found it the other day, its a really nice step-by-step tutorial to use tinymce in the django admin

http://code.djangoproject.com/wiki/AddWYSIWYGEditor

酒废 2024-09-26 11:17:36

谢谢你的回答非常有效,我认为我没有正确表达我的问题,尽管这是我的错,我是 django 的新手。我将tinymce 与django page cms 占位符一起使用。

问题是我的settings.py 它需要以正确的方式进行配置。小问题...

可以通过编辑项目的settings.py 文件来配置应用程序。

TINYMCE_JS_URL (default: settings.MEDIA_URL + 'js/tiny_mce/tiny_mce.js')
    The URL of the TinyMCE javascript file.
TINYMCE_JS_ROOT (default: settings.MEDIA_ROOT + 'js/tiny_mce')
    The filesystem location of the TinyMCE files.
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 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",
}
TINYMCE_SPELLCHECKER = True
TINYMCE_COMPRESSOR = True

取自。
http://django-tinymce .googlecode.com/svn/tags/release-1.5/docs/.build/html/installation.html

Thanks your answers were very valid, I don't think I articulated my question properly though its my fault I am new to django. I was using tinymce with django page cms placeholders.

The problem was my settings.py it needed to be config in the correct way. small issue...

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_ROOT (default: settings.MEDIA_ROOT + 'js/tiny_mce')
    The filesystem location of the TinyMCE files.
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 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",
}
TINYMCE_SPELLCHECKER = True
TINYMCE_COMPRESSOR = True

Taken from.
http://django-tinymce.googlecode.com/svn/tags/release-1.5/docs/.build/html/installation.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文