3 from django
.db
import models
4 from django
.core
.files
.storage
import FileSystemStorage
5 from django
.forms
import ModelForm
7 temp_storage_dir
= tempfile
.mkdtemp()
8 temp_storage
= FileSystemStorage(temp_storage_dir
)
10 class Photo(models
.Model
):
11 title
= models
.CharField(max_length
=30)
12 image
= models
.FileField(storage
=temp_storage
, upload_to
='tests')
14 # Support code for the tests; this keeps track of how many times save()
15 # gets called on each instance.
16 def __init__(self
, *args
, **kwargs
):
17 super(Photo
, self
).__init
__(*args
, **kwargs
)
20 def save(self
, force_insert
=False, force_update
=False):
21 super(Photo
, self
).save(force_insert
, force_update
)
24 class PhotoForm(ModelForm
):