django-stdimage不保存图像

时间:2011-12-05 16:29:37

标签: django

我正在使用django-stdimage并使用ModelForm。提交表单时,它可以毫无问题地保存。存储图像URL但没有图像文件存储在上载的文件夹或任何其他文件夹中。为什么会这样?

import datetime
from django.db import models
from django.forms import ModelForm
from ext.stdimage.fields import StdImageField

from south.modelsinspector import add_introspection_rules
add_introspection_rules([], ["^ext\.stdimage\.fields\.StdImageField"])

class Post(models.Model):
    image = StdImageField(upload_to='uploaded', thumbnail_size=(250, 250))
    date = models.DateTimeField(auto_now=True)
    description = models.TextField(max_length=20000, blank=True)

class PostForm(ModelForm):
    class Meta:
        model = Post
        exclude = ('date')

1 个答案:

答案 0 :(得分:0)

您的表单首先出错:

class PostForm(ModelForm):
    class Meta:
        model = Post
        exclude = ('date') # change this line to this one: exclude = ('date',)

但我觉得问题是你没有安装PIL。

http://code.google.com/p/django-stdimage/source/browse/trunk/stdimage/fields.py#81