0

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?

Hanpan
  • 10,013
  • 25
  • 77
  • 115

1 Answers1

1

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

Wogan
  • 70,277
  • 5
  • 35
  • 35
  • 1
    To explain that a bit more: you can't serve the admin media from `/admin/` because that's where the admin application itself is served from! Also, you may want to consider symlinking the admin files rather than copying them, so that they don't get out of sync if you upgrade your Django version. – Daniel Roseman Apr 04 '11 at 09:25