|
Revision 8304, 0.7 kB
(checked in by gwilson, 1 week ago)
|
Refs #7742 -- Got bug639 regression tests using newforms instead of oldforms.
|
- Property svn:eol-style set to
native
|
| Line | |
|---|
| 1 |
import tempfile |
|---|
| 2 |
|
|---|
| 3 |
from django.db import models |
|---|
| 4 |
from django.core.files.storage import FileSystemStorage |
|---|
| 5 |
from django.forms import ModelForm |
|---|
| 6 |
|
|---|
| 7 |
temp_storage = FileSystemStorage(tempfile.gettempdir()) |
|---|
| 8 |
|
|---|
| 9 |
class Photo(models.Model): |
|---|
| 10 |
title = models.CharField(max_length=30) |
|---|
| 11 |
image = models.FileField(storage=temp_storage, upload_to='tests') |
|---|
| 12 |
|
|---|
| 13 |
# Support code for the tests; this keeps track of how many times save() |
|---|
| 14 |
# gets called on each instance. |
|---|
| 15 |
def __init__(self, *args, **kwargs): |
|---|
| 16 |
super(Photo, self).__init__(*args, **kwargs) |
|---|
| 17 |
self._savecount = 0 |
|---|
| 18 |
|
|---|
| 19 |
def save(self): |
|---|
| 20 |
super(Photo, self).save() |
|---|
| 21 |
self._savecount += 1 |
|---|
| 22 |
|
|---|
| 23 |
class PhotoForm(ModelForm): |
|---|
| 24 |
class Meta: |
|---|
| 25 |
model = Photo |
|---|