2007-02-27 01:17:11 +08:00
|
|
|
import tempfile
|
2008-08-09 04:59:02 +08:00
|
|
|
|
2007-02-27 01:17:11 +08:00
|
|
|
from django.db import models
|
2008-08-09 04:59:02 +08:00
|
|
|
from django.core.files.storage import FileSystemStorage
|
|
|
|
|
|
|
|
temp_storage = FileSystemStorage(tempfile.gettempdir())
|
2007-02-27 01:17:11 +08:00
|
|
|
|
|
|
|
class Photo(models.Model):
|
2007-08-05 13:14:46 +08:00
|
|
|
title = models.CharField(max_length=30)
|
2008-08-09 04:59:02 +08:00
|
|
|
image = models.FileField(storage=temp_storage, upload_to='tests')
|
2007-02-27 01:17:11 +08:00
|
|
|
|
|
|
|
# Support code for the tests; this keeps track of how many times save() gets
|
|
|
|
# called on each instance.
|
|
|
|
def __init__(self, *args, **kwargs):
|
2008-08-09 04:59:02 +08:00
|
|
|
super(Photo, self).__init__(*args, **kwargs)
|
|
|
|
self._savecount = 0
|
2007-02-27 01:17:11 +08:00
|
|
|
|
|
|
|
def save(self):
|
|
|
|
super(Photo, self).save()
|
2008-08-09 04:59:02 +08:00
|
|
|
self._savecount += 1
|