0

The configuration below works fine on my remote host (same dir structure, same django), all admin media are served properly

settings

MEDIA_ROOT = '%s/static/' % FS_ROOT
STATIC_DOC_ROOT = '%s/static/' % FS_ROOT
MEDIA_URL = '/static/'
ADMIN_MEDIA_PREFIX = '%smedia/' % MEDIA_URL

urls

(r'^admin/', include(admin.site.urls)),
(r'^static/(?P<path>.*)$', 'django.views.static.serve',
        {'document_root': '%s/static' % FS_ROOT }),
(r'^media/(?P<path>.*)$', 'django.views.static.serve',
        {'document_root': '%s/media' % FS_ROOT }),

django 1.2.0 @ ubuntu 9.10, http://127.0.0.1:8084/ via runserver_plus

Admin media files are stored under /static/media/ in my project root dir and every static files/dirs under /static/. All statics are served fine, only the admin media are taken from the default django's admin media files. What am I forgetting and why it does affect the project only on my localhost? I've tried to everride /static/media/ path in the urls in various ways, but still nothing.

zalew
  • 10,171
  • 3
  • 29
  • 32

1 Answers1

1

There are two solutions:

  1. You can either set a hostname in ADMIN_MEDIA_PREFIX as suggested in this answer.
  2. Or you can start the development server with the --adminmedia parameter as described in the django documentation.
Community
  • 1
  • 1
Daniel Hepper
  • 28,981
  • 10
  • 72
  • 75
  • cool, it worked. is there some background on it, i mean why i don't have to specify the host on my isp? – zalew Dec 29 '09 at 21:01
  • The docs say: "Normally, the development server serves these files out of the Django source tree magically". It is probably supposed to be convenient. – Daniel Hepper Dec 30 '09 at 19:48