【问题标题】:django ImportError: No module named tiny-mcedjango ImportError:没有名为 tiny-mce 的模块
【发布时间】:2016-06-14 23:00:11
【问题描述】:

我正在运行 django 1.7.2 和 python 2.7。

我有一个测试表单,我想将django-tinymce 添加到我的文本区域。

我已经按照教程here 安装了django-tinymce。

但是,当我尝试运行本地开发服务器时,出现以下错误:

ImportError: No module named tiny-mce

以下是我安装 django-tinymce 的步骤:

  1. 将应用安装到我项目的虚拟环境中。

    pip install django-tinymce
    
  2. 我通过运行 pip freeze (django-tinymce==2.2.0) 确认了上述安装。

  3. 然后我将'tinymce', 添加到我的INSTALLED_APPS

  4. 然后我将(r'^tinymce/', include('tinymce.urls')), 添加到我的网址中。

  5. 然后我将 tinymce js 文件添加到我的插件中,并在我的 base.html 文件中引用了该文件:

    <script src="{{ STATIC_URL }}plugins/tinymce/tinymce.min.js"></script>

我已将以下代码添加到我的 settings.py 文件中:

TINYMCE_JS_URL = os.path.join(STATIC_URL, 'plugins/tinymce/tinymce.min.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

我已仔细检查我已将 django-tinymce 正确安装到正确的虚拟环境中。

我已经搜索过 Google 和 SO,但是当我尝试运行本地开发服务器时,我不知道如何解决我遇到的错误:

ImportError:没有名为 tiny-mce 的模块

编辑

表格代码如下:

from tinymce.widgets import TinyMCE
....
class SummaryDetailsForm(forms.ModelForm):

    required_css_class = 'required'

    def __init__(self, available_languages, language_preference, *args, **kwargs):
        """
        available_languages should be a valid choices list
        """
        super(SummaryDetailsForm, self).__init__(*args, **kwargs)
        self.fields['language_code'] = forms.ChoiceField(choices=available_languages, initial=language_preference, label=_('Language'),)
        summary_details = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 30}))

    class Meta:
        model = SummaryDetails

这是完整的回溯:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Users\6233114\desktop\zoodal\env\lib\site-packages\django\core\manage
ment\__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "C:\Users\6233114\desktop\zoodal\env\lib\site-packages\django\core\manage
ment\__init__.py", line 354, in execute
    django.setup()
  File "C:\Users\6233114\desktop\zoodal\env\lib\site-packages\django\__init__.py
", line 21, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\6233114\desktop\zoodal\env\lib\site-packages\django\apps\regist
ry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "C:\Users\6233114\desktop\zoodal\env\lib\site-packages\django\apps\config
.py", line 87, in create
    module = import_module(entry)
  File "c:\python27\Lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named tiny-mce

【问题讨论】:

  • 你能显示所有的回溯

标签: javascript python django tinymce django-tinymce


【解决方案1】:

您似乎在INSTALLED_APPS 中添加了'tiny-mce' 而不是'tinymce'

【讨论】:

  • 来自问题:3。然后我将“tinymce”添加到我的 INSTALLED_APPS
  • 好吧,我很尴尬。这么愚蠢的错误。感谢您的帮助。
  • @Selcuk,天哪,你说得对,伙计!对不起,我对您的回答有疑问。:)
猜你喜欢
  • 2012-10-21
  • 1970-01-01
  • 2021-01-28
  • 2020-09-07
  • 2018-02-05
  • 2015-07-20
  • 2018-07-28
  • 2023-03-27
  • 2015-08-20
相关资源
最近更新 更多