Django: Admin Media Support

I am trying to serve static files from another domain (subdomain of the current domain). To use all media files, I used the following settings:

MEDIA_URL = ' http://media.bud-inform.co.ua/ '

So when in the template I used

{{MEDIA_URL}}

he replaced the above setting. Now I'm trying to serve administrator media files from the same subdomain, I changed the settings this way:

ADMIN_MEDIA_PREFIX = ' http://media.bud-inform.co.ua/admin_media/ ',

and expected all media calls from my admin site to be made to this URL. But actually it didn’t work, I still see CSS paths made as follows:

http://bud-inform.co.ua/media/css/login.css

Could you suggest how to properly use the administrator’s media files.

+4
source share
1 answer

MEDIA_URL and ADMIN_MEDIA_PREFIX are two different things. One of them is the location of your media files, and the other is the location of the media files of the django admin system.

You need to make sure that ADMIN_MEDIA_PREFIX points to where you are actually serving as a media administrator. Django does not complete this step for you.

The django administration tools are located in django/contrib/admin/media/ . Copy or symbolically link to this directory somewhere public and set ADMIN_MEDIA_PREFIX to reflect where you placed it.

+2
source

All Articles