Django ImportError:没有名为tinym的模块

2024-10-01 15:28:47 发布

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

我运行的是django1.7.2和python2.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')),添加到我的url中。

  5. 然后我将tinymce js文件添加到插件中,并在我的基本.html文件:

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

我在我的设置.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正确安装到正确的虚拟环境中。在

我搜索过谷歌,但当我试图运行我的本地开发服务器时,我不知道如何解决我的错误:

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

Tags: djangoinpyenvinitlibpackagesline

热门问题