Wrong path return by a FileField in Django

406 Views Asked by At

I've got a FileField with the following upload_to option:

def get_file_path(instance, filename):
    return os.path.join('rapports/rapports_journaliers', filename)

class ListPCA(models.Model): 
    pdf_file = models.FileField(upload_to=get_file_path)

My files are properly saved in <MEDIA_ROOT>/rapports/rapports_journaliers/<filename>

but the path returned by

list_pca_instance.pdf_file.path

is wrong:

<MEDIA_ROOT>/<filename>

Anybody can help?

Thanks

0

There are 0 best solutions below