Django FileSystemStorage does not save anything to media folder

I'm working on a Django backend deployed on a server, here's my settings:

DEBUG = False

STATIC_URL = "/staticfiles/"
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")

MEDIA_URL = "/media/"
MEDIA_ROOT = os.path.join(BASE_DIR, "media")

And I want to save the users' images outside the django folder, so I've created a custom FileSystemStorage in this way:

from import FileSystemStorage
key_store = FileSystemStorage(location="/home/usr/project/media/", base_url="/media")

Where I put the absolute path of ubuntu server.

def profile_picture_url(instance, *_):
    return f"{instance.user.uuid}/profile.picture.png"

picture = models.FileField(
  storage=key_store, default=None, upload_to=profile_picture_url

But it doesn't create any file inside media folder. Any solution?

Back to Top