Practical Django Projects 2nd Ed. (Apress) – CH3 TinyMCE Problem

Updated: April 6, 2010 9:50pm CST – Correction (Below)

When reading/working through the 2nd edition of Apress’ ‘Practical Django Projects’, I hit a hang.  A big hang.  And like most big hangs, it was actually a very small (technically speaking) bump in the road.   The problem is that when looking to “how to” books such as ‘Practical Django Projects’, it is easy to fall back to the book’s printed text as the absolute code bible of what is and what is not correct in this world of code.  Unfortunatly, as was the case with me, this can lead to wasted hours and (after-the-fact) embarrassing frustration.

As I have seen this mentioned on forums around the interwebs while researching this myself, I figured I would document the solution here.  I am happy to say that I do not have to cite reference here as I figured this out myself and have submitted an errata report to the publisher.  What I am not as happy to admit is the fact that when you see what the problem here is, you will not be impressed (and will likely kick yourself as clearly you are reading this for help – and don’t really need it)…  So on to the meat…

PG.24-25 – the tiny_mce.js referral to load TinyMCE in your Flatpages… You set it up, just as the book instructs and BAM – nothing… No TinyMCE and a Firebug inspection of the page shows that the tiny_mce.js cannot be found (404).. Again, the error is actually quite simple, of course making it all the more simple to overlook when error correcting…

On page 24, the reader is instructed to set ‘document_root’:’/path/to/tiny_mce’.  In the explanatory following paragraph, the example directory “/Users/jbennett/javascript/TinyMCE/jscripts/tiny_mce” is given.

On page 25, the reader is told to set the TinyMCE script up on the template as follows: <script type=”text/javascript” src=”/tiny_mce/tiny_mce.js”></script>.  Since we already set the document_root (pg25) to ‘../jscripts/tiny_mce/’, the ‘tiny_mce” portion is not needed here and of course is not a valid src referral as the tiny_mce.js is located in ‘../tiny_mce/’ and not in ‘../tiny_mce/tiny_mce/.

Hope this helps someone…

UPDATE:  Ok, so stepping back to it today, I don’t know quite what I was thinking last night and am sorry to Apress for incorrectly identifying this supposed error.  In reworking through this, the text it 100% correct.  I am blaming the lack of sleep for my confusion (because that is less of an ego blow than blaming stupidity).  My misunderstanding came about from a ASSumption made by me on the meaning of document_root and the Javascript referral.  Reading this helped me better understand where the two meet (aka not a literal direct path relationship): How To Serve Static Files… The “How to do it” section pretty much sums it up :)  Sorry for my confusion!!!

3 thoughts on “Practical Django Projects 2nd Ed. (Apress) – CH3 TinyMCE Problem

  1. Eden Mondragon

    Would you be able to share your code? I was trying to work through this example myself but am having trouble getting the TinyMCE to come up on the admin page.

    1. mattezell

      I am sorry, Eden. I have not worked with Django or Python in a number of months and no longer have this readily available due to a hard drive crash… I hope that you have been able to find what you needed.

Leave a Reply