def generate_uuid_file_name(self, filename):
self.original_filename = filename
extension = filename.rsplit('.', 1)[1]
newfilename = uuid.uuid4().__str__() + '.' + extension
return self.directory() + newfilename
class FileUpload(models.Model):
original_filename = models.CharField(max_length=128)
fileobj = models.FileField(upload_to=generate_uuid_file_name)
On upload,
{"errors": {"original_filename": ["This field is required."]}, "success": false}
Adding blank=True, null=True to the FileUpload.original_filename allows the upload to succeed but does not save the original file name. On Django 1.5. According to this post, this should work.