problem adding tinyMCE to admin

51 views
Skip to first unread message

Frijole

unread,
Aug 7, 2008, 10:15:50 PM8/7/08
to Django users
I am working through "Practical Django Projects" and I am trying to
get the rich text editing set up. The book was written somewhere
around 0.97a and I am on the trunk. The book says to configure my
urls.py like this:

(r'^tiny_mce/(?P<path>.*)$', 'django.views.static.serve',
{ 'document_root': /pathToTinyMCE'},)

When I run this, the dev server says:

[07/Aug/2008 19:08:25] "GET /admin/flatpages/flatpage/1/ HTTP/1.1" 200
5123
[07/Aug/2008 19:08:25] "GET /admin/jsi18n/ HTTP/1.1" 200 803
[07/Aug/2008 19:08:25] "GET /tiny_mce/tiny_mce.js HTTP/1.1" 404 1761

so, it seems like it is finding the file. But, nothing shows up in the
textarea, it just looks the same as before. Also, here is the code I
had to add to the template.

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

This addition is in the template in the directory:

admin/flatpages/flatpage/change_form.html

Which seems like it is working because of the GET in the dev server
output. I don't know what else to try. Does anyone know what is going
on with this? Thanks in advance, sorry for the wordy question.

I am running Ubuntu 8.04 btw, python 2.5, django-trunk

Jeff Balogh

unread,
Aug 7, 2008, 11:08:23 PM8/7/08
to django-users
joelklabo wrote:
>
> I am working through "Practical Django Projects" and I am trying to
> get the rich text editing set up. The book was written somewhere
> around 0.97a and I am on the trunk. The book says to configure my
> urls.py like this:
>
> (r'^tiny_mce/(?P<path>.*)$', 'django.views.static.serve',
> { 'document_root': /pathToTinyMCE'},)
>
> When I run this, the dev server says:
>
> [07/Aug/2008 19:08:25] "GET /admin/flatpages/flatpage/1/ HTTP/1.1" 200
> 5123
> [07/Aug/2008 19:08:25] "GET /admin/jsi18n/ HTTP/1.1" 200 803
> [07/Aug/2008 19:08:25] "GET /tiny_mce/tiny_mce.js HTTP/1.1" 404 1761
>
> so, it seems like it is finding the file. But, nothing shows up in the
> textarea, it just looks the same as before. Also, here is the code I
> had to add to the template.

Actually, it's not finding the file:

[07/Aug/2008 19:08:25] "GET /tiny_mce/tiny_mce.js HTTP/1.1" 404 1761

^^^

The 404 means the file wasn't found[1]. Try going to
http://localhost:8000/tiny_mce/tiny_mce.js (change the port if necessary).
Django will tell you the local path where it's looking for tiny_mce.js. Also,
you can turn on directory listings[2] if that's easier, and browse tiny_mce.

> <script type="text/javascript" src="/tiny_mce/tiny_mce.js"</script>
> <script type="text/javascript">
> tinyMCE.init({
> mode: "textareas",
> theme: "simple"
> });
> </script>
>
> This addition is in the template in the directory:
>
> admin/flatpages/flatpage/change_form.html
>
> Which seems like it is working because of the GET in the dev server
> output. I don't know what else to try. Does anyone know what is going
> on with this? Thanks in advance, sorry for the wordy question.
>
> I am running Ubuntu 8.04 btw, python 2.5, django-trunk

Cheers,
jeff

[1]: http://en.wikipedia.org/wiki/HTTP_404
[2]: http://www.djangoproject.com/documentation/static_files/#directory-listings

Joshua Jonah

unread,
Aug 7, 2008, 10:46:10 PM8/7/08
to django...@googlegroups.com
"so, it seems like it is finding the file."

It says "GET /tiny_mce/tiny_mce.js HTTP/1.1" 404, thats means it cant find the file.

I would try typing that file in your vrowser directly and se if you can get to it, if not, it's a media path issue.

Joshua

Clinton De Young

unread,
Aug 8, 2008, 12:08:28 AM8/8/08
to django...@googlegroups.com
Normally, when you unzip TinyMCE, it creates a directory structure that looks like this:

/tiny_mce/jscripts/tiny_mce/tiny_mce.js

Make sure you are pointing at /tiny_mce/jscripts/tiny_mce in your urls.py directory.  I've seen a lot of people point to the root tiny_mce directory, which is wrong.

Your urls.py should have a line like this:
(r'^tinymce/(?P<path>.*)$', 'django.views.static.serve', {'document_root': ..../media/tiny_mce/jscripts/tiny_mce')}),

NOTE:  Make sure not to put the .... in your path.  I just did that because your path is going to be different that mine prior to your media directory.

klaut

unread,
Aug 8, 2008, 7:28:46 AM8/8/08
to Django users

hi,
I was having the same problem a couple of days ago. Everything was
right, i had everything in the path but still the richtext editor
wouldn't show up.
The trick that did for me was to make sure that the line
(r'^tiny_mce/(?P<path>.*)$', 'django.views.static.serve',
{ 'document_root': /pathToTinyMCE'},)
in the urls.py comes BEFORE the generic catchall line
(r'', include('django.contrib.flatpages.urls'))
Before i had put it at the end and of course, the generic catchall was
getting to my tinyMCE before it.

i hope it helps.

Al

unread,
Aug 8, 2008, 8:18:33 AM8/8/08
to Django users
Can someone who's managed to get this working please send me their
code? I've followed the book, and tried what people have suggested
here, but the rich text editor still isn't showing.
Thanks

Donn

unread,
Aug 8, 2008, 9:28:36 AM8/8/08
to django...@googlegroups.com
For great tinymce advice, go see:
http://code.djangoproject.com/wiki/AddWYSIWYGEditor

\d

Joel Klabo

unread,
Aug 8, 2008, 12:46:53 PM8/8/08
to Django users
Does anyone know where I could go to learn what is going on here?
--
Joel Klabo | joel...@gmail.com | 408.506.6759

Donn

unread,
Aug 8, 2008, 12:58:23 PM8/8/08
to django...@googlegroups.com
On Friday, 08 August 2008 18:46:53 Joel Klabo wrote:
> Does anyone know where I could go to learn what is going on here?

http://code.djangoproject.com/wiki/AddWYSIWYGEditor


\d

Sunny

unread,
Aug 17, 2008, 12:20:21 PM8/17/08
to Django users
Hi I did exactly as klaut mentioned

> The trick that did for me was to make sure that the line
> (r'^tiny_mce/(?P<path>.*)$', 'django.views.static.serve',
> { 'document_root': /pathToTinyMCE'},)
> in the urls.py comes BEFORE the generic catchall line
> (r'', include('django.contrib.flatpages.urls'))

Surprisingly it worked. I don't know the reason behind it and I'm
hoping someone could explain to me anyway.
Thanks klaut I wasted a day on this :)


On Aug 8, 6:28 pm, klaut <tanja.pis...@gmail.com> wrote:
> hi,
> I was having the sameproblema couple of days ago. Everything was
> right, i had everything in the path but still the richtext editor
> wouldn't show up.
> The trick that did for me was to make sure that the line
> (r'^tiny_mce/(?P<path>.*)$', 'django.views.static.serve',
> { 'document_root': /pathToTinyMCE'},)
> in the urls.py comes BEFORE the generic catchall line
> (r'', include('django.contrib.flatpages.urls'))
> Before i had put it at the end and of course, the generic catchall was
> getting to mytinyMCEbefore it.
>
> i hope it helps.

Malcolm Tredinnick

unread,
Aug 17, 2008, 12:25:32 PM8/17/08
to django...@googlegroups.com

On Sun, 2008-08-17 at 09:20 -0700, Sunny wrote:
> Hi I did exactly as klaut mentioned
>
> > The trick that did for me was to make sure that the line
> > (r'^tiny_mce/(?P<path>.*)$', 'django.views.static.serve',
> > { 'document_root': /pathToTinyMCE'},)
> > in the urls.py comes BEFORE the generic catchall line
> > (r'', include('django.contrib.flatpages.urls'))
>
> Surprisingly it worked. I don't know the reason behind it and I'm
> hoping someone could explain to me anyway.

Because URL patterns are processed top to bottom until one of the
patterns causes a match. The second pattern, above, will catch
everything, so anything else needs to come before it.

Regards,
Malcolm


Reply all
Reply to author
Forward
0 new messages