How to change URL for all already uploaded files in filefield after changing upload_to

Viewed 15

I had to migrate my Django application to different server but I already have many uploaded files "into" filefield originally defined as below:

    image = models.FileField(upload_to="uploads", verbose_name=_(
        "Team Strips"), help_text=_("A Strip to be used later by users"))

But at the new server I'm forced to use a different path so I changed model definition and settings as below

models.py

    image = models.FileField(upload_to="ldawri_django/uploads/uploads", verbose_name=_(
        "Team Strips"), help_text=_("A Strip to be used later by users"))

settings.py

MEDIA_ROOT = '/home/wateopjw/l-dawri.com/ldawri_django/uploads/'
MEDIA_URL = "ldawri_django/uploads/"

The Problem

After changing the server and upload_to parameter all images are not showing now inside the Admin panel. But it is shown when I click open image in new tab.

What I've tried

Tried to re-upload one of the files and it worked like charm .. so that will force me to reupload all files .. that is kinda impossible because there are hundreds of images .

What I need

A function or method to help me simulate some kind of reuploading for all images so the link inside the admin site is fixed

0 Answers
Related