views:

229

answers:

3

I am trying to run WMDEditor in my Django site. I have installed WMD files in a directory called /static/js/wmd.wmd.js of the root of my website.

However when the page get served I get:

INFO     2009-09-08 11:00:48,217 dev_appserver.py:3034] "GET /static/js/wmd/wmd.
js HTTP/1.1" 302 -
INFO     2009-09-08 11:00:48,733 dev_appserver.py:3034] "GET /static/js/wmd/wmd.
js/ HTTP/1.1" 404 -
A: 

What is happening is a redirect, because Django thinks your URLs should end with a slash (/), but even with a slash at the end, the url is obviously incorrect.

Add this to your root urls.py file and make sure that settings.MEDIA_ROOT is an absolute path to your static directory:

urlpatterns += patterns('',
    (r'^static/(?P<path>.*)$', 'django.views.static.serve',
        {'document_root': settings.MEDIA_ROOT}),
)

Also note that in a production setting static files should not be served by Django.

stefanw
A: 

The django dev server serves admin static files automagically.

However, I don't know how it behaves with static files you yourself add. I've gotten the WMDEditor working in a production enviroment, but not a dev one.

This article outlines how to get a hackish way to work in the dev enviroment to serve static files. You'll want to set up an alias in the production enviroment however.

Tom Ritter
A: 

I had some similar problems. Make sure you also add to your app.yaml file

handlers:
- url: /static
  static_dir: static
Peter Newman
That did it. Thanks Peter.
Jack Smies