Search code examples
djangodjango-admindjango-media

Django 1.3 - Simple media deployment


I having some real trouble getting django to play nice with my media setup. I am not using staticfiles since I am have no need for a CDN at this point of the project and I want to keep it simple.

My folder structure looks like this:

/static
    /admin
        /css
        /js
        /etc
    /css
    /js
    /images

The admin folder is a copy of the admin contrib media folder... since I am using mod_wsgi I know that this can't live in the django project folder.

My settings file:

MEDIA_ROOT = os.path.join(PROJECT_DIR, 'static/')
MEDIA_URL = 'http://127.0.0.1:8000/static/'
ADMIN_MEDIA_PREFIX = 'admin/' (tried with leading slash too)

Urls:

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

No matter what I try, I can't get the admin media to serve. I know from reading the documentation that the ADMIN_MEDIA_PREFIX has to be very different from the normal media url, but I need to be able to serve the files outside of the system django folder because of mod_wsgi.

Can anyone help?


Solution

  • For your setup, ADMIN_MEDIA_PREFIX = MEDIA_URL + 'admin/' should work.