我有以下文件的ImageField当保存按钮被按下没有被清除:Django的管理
models.py
类旅行(models.Model)
featured = models.BooleanField(default=False, help_text='Tags this trip as a featured trip.')
top_ten_trip = models.BooleanField(default=False)
header_image = models.ImageField(help_text='This is the image shown when viewing the details for this trip.', upload_to='images/', blank=True, null=True)
map_image = models.ImageField(help_text='The map image for this trip.', upload_to='images/', blank=True, null=True)
.....
等
admin.py
class TripAdmin(admin.ModelAdmin):
list_display = ('name', 'code', 'category', 'supplier', 'active', 'featured', 'top_ten_trip',)
search_fields = ('name', 'code',)
list_filter = ('category', 'featured', 'top_ten_trip',)
filter_horizontal = ('countries', 'related_trips',)
场出现在管理这样的事情 标题图片浏览按钮:目前:图像/ comfort_japan.jpg 变化:删除这个文件
地图图像:目前:图像/ map_japan_.jpg 变化:删除这个文件
现在的问题: - 当我点击删除此镜像文件(图片/ comfort_japan.jpg)得到它删除了那个瞬间,但是当我按下节省管理员按钮不会删除。
我想要当我点击删除这个文件,然后按保存它应该被删除。
我在做什么错误或错过了什么?
在此先感谢。
我想要的是Django1.4b包含的ImageField。要求清晰图像的复选框。如何实现该功能?我正在通过Django 1.4b代码来查找真的很难弄清楚他们做了什么。我在Django1.2.5中。我如何使用post_save信号来实现这个 – 2012-03-04 12:27:11
@the_game清除复选框(如果为空白,则显示在图像名称旁边= True'被设置在ImageField上时)只选择从模型(db)中删除图像,但不从磁盘上删除它。用信号覆盖此检查[this](http://obroll.com/automatically-delete-file-in-filefield-django-1-3-when-object-record-deleted/) – Scillon 2012-03-04 14:19:18
写我同意它只会删除而不是删除。这段代码也删除但不删除。正如我已经搜索删除是更好的办法,而不是删除,但谢谢我提出了一些信号的概念 – 2012-03-05 11:29:22