Reputation: 3
So i have two Django projects, a main and a child-site, both are running on separate servers with separate domain-names. The media files are stored on and can only be posted to the main site, but the child-site has to access those media files somehow.
How can i configure the MEDIA_ROOT setting (or something else, for that matter, in my project) so that the media files are automatically fetched from my main site. Or what changes can i make so that a fixed URL (of my main site) is added as a prefix when addressing any sort of media file.
P.S. i am using pythonanywhere (two beginner/free accts., one for each site).
Upvotes: 0
Views: 631
Reputation: 3806
I think you can simply ignore MEDIA_ROOT
and set MEDIA_URL
. MEDIA_ROOT
is used to fetch resources where MEDIA_URL
is used to build the url.
@see https://docs.djangoproject.com/en/3.0/ref/settings/#std:setting-MEDIA_URL
Please read the difference between MEDIA_
and STATIC_
. MEDIA is for user-uploaded files.
More at:
https://docs.djangoproject.com/en/3.0/topics/files/
https://docs.djangoproject.com/en/3.0/howto/static-files/
Upvotes: 1