3
我希望能夠上傳文件,並在每次上傳時使用最新版本覆蓋/替換現有文件。如何更換/覆蓋上傳的文件?
from django.core.files.storage import FileSystemStorage
fs = FileSystemStorage(location='C:/temp', base_url='/attachments')
class Import(models.Model):
file = models.FileField(upload_to='data', storage=fs)
如果任何人有興趣在此解決方案,請參閱[Thnee回答這裏(http://stackoverflow.com/questions/4394194/replacing-a-django-image-doesnt-delete-original)的更多的相關詳細說明 – 2013-02-04 16:10:51