mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
File storage refactoring, adding far more flexibility to Django's file handling. The new files.txt document has details of the new features.
This is a backwards-incompatible change; consult BackwardsIncompatibleChanges for details. Fixes #3567, #3621, #4345, #5361, #5655, #7415. Many thanks to Marty Alchin who did the vast majority of this work. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8244 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import tempfile
|
||||
import os
|
||||
from django.db import models
|
||||
from django.core.files.storage import FileSystemStorage
|
||||
|
||||
UPLOAD_ROOT = tempfile.mkdtemp()
|
||||
UPLOAD_TO = os.path.join(UPLOAD_ROOT, 'test_upload')
|
||||
temp_storage = FileSystemStorage(tempfile.mkdtemp())
|
||||
UPLOAD_TO = os.path.join(temp_storage.location, 'test_upload')
|
||||
|
||||
class FileModel(models.Model):
|
||||
testfile = models.FileField(upload_to=UPLOAD_TO)
|
||||
testfile = models.FileField(storage=temp_storage, upload_to='test_upload')
|
||||
|
||||
Reference in New Issue
Block a user