无论如何,TinyMCE都没有出现

时间:2011-03-07 19:53:58

标签: django tinymce

现在这不是django-tinymce,因为我在其他页面上不需要它。只有这一页,并没有显示它让我头疼。在检查Firebug时正确看到tiny_mce.js,并且在控制台上没有任何javascript错误。我甚至尝试过模式:'exact'和element:'id_description'但是nada。

{% block content %}
<script type="text/javascript" src="/static/js/tiny_mce.js"></script>
<script type="text/javascript">
  tinyMCE.init({
      mode : "textareas",
      theme : "simple"
  });
</script>  

<form class="myform" action="{{ form_action }}" method="post">{% csrf_token %}
    <ul>        
        <li><label for="id_description">Description:</label>
            <textarea name="description" cols="40" rows="10" id="id_description"></textarea>
        </li>        
    </ul>
    <input type="submit" value="Submit" />
</form>

{% endblock %}

3 个答案:

答案 0 :(得分:3)

多年来我没有触及过这个问题,但我记得我无法使textareas模式起作用。相反,我必须使用exact模式并指定特定表单元素的ID:

{ mode : "exact",
  elements : "id_description" }

答案 1 :(得分:2)

我得到了它的工作。我只需要复制整个tiny_mce /文件夹(我只放置tiny_mce.js脚本),然后相应地更新我的脚本标记:

<script type="text/javascript" src="/static/js/tiny_mce/tiny_mce.js"></script>

我认为这是因为runserver屏幕显示了一些非常可疑的错误消息:

[07/Mar/2011 21:31:16] "GET /static/js/themes/simple/editor_template.js HTTP/1.1" 302 0
Traceback (most recent call last):
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/servers/basehttp.py", line 280, in run
    self.result = application(self.environ, self.start_response)
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/servers/basehttp.py", line 674, in __call__
    return self.application(environ, start_response)
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/handlers/wsgi.py", line 245, in __call__
    response = middleware_method(request, response)
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/middleware/common.py", line 97, in process_response
    % (referer, request.get_full_path(), ua, ip))
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/mail/__init__.py", line 101, in mail_managers
    connection=connection).send(fail_silently=fail_silently)
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/mail/message.py", line 175, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/mail/backends/smtp.py", line 78, in send_messages
    new_conn_created = self.open()
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/mail/backends/smtp.py", line 41, in open
    local_hostname=DNS_NAME.get_fqdn())
  File "/usr/lib/python2.6/smtplib.py", line 239, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/lib/python2.6/smtplib.py", line 295, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/lib/python2.6/smtplib.py", line 273, in _get_socket
    return socket.create_connection((port, host), timeout)
  File "/usr/lib/python2.6/socket.py", line 514, in create_connection
    raise error, msg
error: [Errno 111] Connection refused
[07/Mar/2011 21:31:16] "GET /static/js/langs/en.js/ HTTP/1.1" 500 2102
Traceback (most recent call last):
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/servers/basehttp.py", line 280, in run
    self.result = application(self.environ, self.start_response)
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/servers/basehttp.py", line 674, in __call__
    return self.application(environ, start_response)
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/handlers/wsgi.py", line 245, in __call__
    response = middleware_method(request, response)
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/middleware/common.py", line 97, in process_response
    % (referer, request.get_full_path(), ua, ip))
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/mail/__init__.py", line 101, in mail_managers
    connection=connection).send(fail_silently=fail_silently)
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/mail/message.py", line 175, in send
    return self.get_connection(fail_silently).send_messages([self])
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/mail/backends/smtp.py", line 78, in send_messages
    new_conn_created = self.open()
  File "~/virtualenv_setup/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/core/mail/backends/smtp.py", line 41, in open
    local_hostname=DNS_NAME.get_fqdn())
  File "/usr/lib/python2.6/smtplib.py", line 239, in __init__
    (code, msg) = self.connect(host, port)
  File "/usr/lib/python2.6/smtplib.py", line 295, in connect
    self.sock = self._get_socket(host, port, self.timeout)
  File "/usr/lib/python2.6/smtplib.py", line 273, in _get_socket
    return socket.create_connection((port, host), timeout)
  File "/usr/lib/python2.6/socket.py", line 514, in create_connection
    raise error, msg
error: [Errno 111] Connection refused
[07/Mar/2011 21:31:16] "GET /static/js/themes/simple/editor_template.js/ HTTP/1.1" 500 2102

答案 2 :(得分:0)

你需要在init上指定哪个控件来制作tinyMCE。

<script type="text/javascript">
tinyMCE.init({
mode : "textareas", elements: "id_description",
theme : "simple"
});
</script>