我有以下文件的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