2

Here is my setup:

urls.py

....
    url(r'^tinymce/', include('tinymce.urls')),
....

settings.py

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

TINYMCE_DEFAULT_CONFIG = {
    "theme_advanced_buttons1": ("formatselect,"
    "separator, bold, italic, "
    "underline, strikethrough, separator,"
    "justifyleft,justifycenter, justifyright,"
    "justifyfull, separator, bullist, numlist,"
    "separator, link, code")
}
TINYMCE_SPELLCHECKER = False
TINYMCE_COMPRESSOR = False
TINYMCE_JS_URL = '/static/js/tiny_mce/tiny_mce.js'
TINYMCE_JS_ROOT = '/static/js/tiny_mce'

my_template.html

{% extends '_layout.html' %}

{% block extra_head %}
  {{ form.media }}
{% endblock %}

forms.py

class VenueForm(ModelForm):

    .....

    class Meta:
        widgets = {
            'description': TinyMCE(attrs={'cols': 100, 'rows': 10}),
        }

I've been searching through the documentation and other SO threads and I thought I had set it correctly. However, I'm getting the error:

ReferenceError: django is not defined


}(django.jQuery));

which is the last line in static/django_tinymce/init_tinymce.js. All my resources are loading fine, no 404 error in the console What am I missing? I've been struggling with this for the past two hours. Thank you

Mihai Zamfir
  • 2,167
  • 4
  • 22
  • 37

2 Answers2

3

Sorry for I have to answer to my own question, is like giving a like on facebook to myself :)

But I found the solution and this might be helpful for other people.

I installed the latest version which is django-tinymce==1.5.3. This has a bug. I downgraded to 1.5.2 and everything went perfectly. Waiting for the bug to be fixed and looking forward to see 1.5.4

Mihai Zamfir
  • 2,167
  • 4
  • 22
  • 37
  • 1
    Answering your own question is encouraged with a badge: http://stackoverflow.com/help/badges/14/self-learner . You should accept your own answer. – xbello Sep 15 '16 at 10:50
2

This workaround helped me out, without having to downgrade django-tinymce. You just have to define django on your template before {{ form.media }}:

<script>
  var django = {jQuery: jQuery};
</script>
{{ form.media }}

I hope this helps.

felix
  • 446
  • 5
  • 10