How to update the filename of a Django's FileField instance ?
- by pierre-guillaume-degans
Hello,
Here a simple django model:
class SomeModel(models.Model):
title = models.CharField(max_length=100)
video = models.FileField(upload_to='video')
I would like to save any instance so that the video's file name would be a valid file name of the title.
For example, in the admin interface, I load a new instance with title "Lorem ipsum" and a video called "video.avi". The copy of the file on the server should be "Lorem Ipsum.avi" (or "Lorem_Ipsum.avi").
Thank you :)