views:

2703

answers:

8

I’m working on a web application with Django, and I’m using the Flatpages app.

Now, I’m trying to embed the TinyMCE WYSIWYG editor in Flatpages. I’m following the steps mentioned in the Apress book: Practical Django Projects. And I’ve done everything right, but the TinyMCE app wouldn’t show up in the browser. When I asked the Django IRC channel we found out that it’s not a Django problem, the problem seems to be with TinyMCE itself. When I tried to look up the documentation at the TinyMCE website, all I found was either very outdated, or totally unrelated to my problem. Any hints on how should I go about this?

+2  A: 

Have you tried django-tinymce?

ohnoes
+1  A: 

I've been following the Practical Django Projects book myself. I got the TinyMCE embedded a few days ago as well. I can help, but I need a bit more info. Show me the line on the template where you include the TinyMCE javascript file. Also, describe where you placed the TinyMCE folder. I'm pretty sure your problem is that the script include reference doesn't match with the actual directory location.

fuentesjr
+1  A: 

A useful first check with JavaScript problems is to make sure all scripts are loaded. Take a look at the HTML source of the generated page in the browser, find all <script src="..."> tags and check that their paths are accessible.

You could also look at the terminal where you run the Django development server, or the "Net" tab of Firebug.

akaihola
+2  A: 

Author James Bennett has put up the source code for Second Edition of the book so you can either: check your code against that, or simply download and use his code.

However, there are two specific questions that you need to answer before further help:

  1. which version of the book? (Second Edition covers Django 1.1, i.e. from trunk)

  2. which version of Django are you using?

  3. which version of python do you have (python -V)?

If you're using the Second Edition and have svn'd Django from trunk, I can help - I have it working fine. Here's my (OS X) setup (just for working through the Second Edition of the book with Django from trunk):

in settings.py:

TEMPLATE_DIRS = (
    '/Users/[myhome]/Sites/django-templates/cms/',
)

in urls.py:

(r'^tiny_mce/(?P<path>.*)$', 'django.views.static.serve',
      { 'document_root': '/Users/[myhome]/djangocode/cms/jscripts/tiny_mce/' }),

Then there's the copy of change_form.html duplicated from the django directory and copied to:

/django-templates/cms/admin/flatpages/flatpage/

which includes:

{{ media }}
<script type="text/javascript" src="/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
  mode: "textareas",
  theme: "simple" //or use advanced
});
</script>
{% endblock %}

Have a look through that and let us know how you get on!

Dave Everitt
+3  A: 

I had the django app but have ditched it in favour of: http://code.djangoproject.com/wiki/AddWYSIWYGEditor

The instructions were simple and easy to follow - especially the flatpage bit.

The only real issue I had was having to set MEDIA_URL as a relative value. Until I did that - all my pop-up windows for links and html etc were blank!

A: 

@omar: i have the same problem with tiny mce.

@mtod: django-tinymce i tried but i can understand the doc about the model flatpage.

Asinox
Thanks artemis6c is working with ur link :)
Asinox
A: 

You can view the change_form.html code, which resides in my /[path to templates]/[project name]/admin/flatpages/flatpage/ and it works like a charm: http://pastebin.com/f21a1cd97

PythonUser
A: 

Can you show me your URL file?

Neech