the_game
the_game

Reputation: 261

ImageField not getting deleted when save button is pressed : Django-admin

i have the following files

models.py

Class Trip(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)
.....

and so on

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',)

The field appear with browse button in admin something like this Header image: Currently: images/comfort_japan.jpg Change: Delete this file

Map image: Currently: images/map_japan_.jpg Change: Delete this file

Now the Problem :- When i click on Delete this imagefile( images/comfort_japan.jpg ) it get removed for that instant but does not deleted when i press save button on admin.

I want when i click on delete this file and press save it should get deleted.

What mistake i am doing or what am i missing ?

Thanks in advance.

Upvotes: 2

Views: 1274

Answers (2)

the_game
the_game

Reputation: 261

Hi All I solved my problem by using snippet 1633

http://djangosnippets.org/snippets/1633/ .It works pretty fine.

Upvotes: 0

Scillon
Scillon

Reputation: 320

This was intentionally changed in Django 1.3, see Django Ticket #15224.
You need to implement file deletion yourself. Check related posts:

Upvotes: 2

Related Questions