TinyMCE and Static File Optimization Working

Ok, so I was supposed to be working on RSS feeds, and that's what I'll be doing for the remainder of this evening, but I really wanted to get two (related) things figured out: I wanted to use the TinyMCE editor to create entries, and I wanted to serve the static javascript that makes up TinyMCE from my web host's main server instead of Django. Django adds absolutely no value to the equation when it comes to serving static files. In fact, it says right in the documentation that Django is not optimized for serving static files, and that you SHOULD NOT have Django serving static files in production.

I was a little confused at first, but after a while of thinking about it, it came to me: if you're not serving the files from Django, you don't really need to configure Django to do anything at all! I'd been following "Practical Django Projects", which assumes the use of the built-in dev server throughout the book (at least through Chapter 7 -- and a glance at the index seems to confirm that it's just not in the book at all), so it uses a Django helper view to serve static files, because if you're only using the dev server, there's no other choice. So my brian was stuck for a bit on the question "if I don't use Django to serve this stuff, what do I replace that view name with in the URLConf?" -- the answer is "you shouldn't have a URLConf for stuff Django isn't serving!

Well, at least that's the conclusion I came to. If someone knows better, let me know. My web host is webfaction, and the way they're set up is that there's a "main" Apache instance, and there's also the Apache instance that is configured with mod_wsgi, and then I tell it to go grab my django.wsgi file, and that tells it everything it needs to know to pass requests through to Django. I believe I could've actually had the mod_wsgi Apache instance serve the static files by setting up a handler of "none" for specific URLs, but why not remove the instance from the equation altogether, and just have the main Apache instance do it? It's not doing anything else anyway (other sites I host there have their own Apache instances as well).

So, since I use the standard admin interface to edit/create entries on my blog, I just entered the standard <script> code into a copy of the change_form.html file, and used the path to TinyMCE in that code, and it worked. I'll keep thinking about a way to do this without hard-coding that path in the template file, but at least it's working.

Post a comment

Comments (there are 0 comments so far)