[Fixed]-How to skip using MEDIA_ROOT and MEDIA_URL in a single specific case

1👍

MEDIA_ROOT & MEDIA_URL are different, MEDIA_ROOT means you are storing the media files there.. but MEDIA_URL is the url through you can access the file

extend FileSystemStorage class and set base_url value

class MyStorage(FileSystemStorage):
      base_url = '/custom/url/'

fs = MyStorage(location=settings.STATIC_ROOT + '/XML_Uploads/')

class ImporterFile(models.Model):
    file = models.FileField(storage=fs)

Leave a comment