dzxs / django-photologue

Automatically exported from code.google.com/p/django-photologue
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

In Django 1.3, FileField no longer deletes files #162

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run the Photologue tests

What is the expected output? What do you see instead?

I would expect them all to succeed, but instead they all fail with errors much 
like this one:

ERROR: test_resize_and_crop (photologue.tests.ImageResizeTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "… /eggs/django_photologue-2.3-py2.6.egg/photologue/tests.py", line 104, in tearDown
    super(ImageResizeTest, self).tearDown()
  File "… /eggs/django_photologue-2.3-py2.6.egg/photologue/tests.py", line 34, in tearDown
    self.failIf(os.path.isfile(path))
AssertionError: True is not False

The reason is that Photologue relies on Django to delete the file that is 
associated with the ImageField (a FileField), but in Django 1.3, the intended 
behavior is to leave it untouched.

http://docs.djangoproject.com/en/dev/releases/1.3/#filefield-no-longer-deletes-f
iles
http://haineault.com/blog/147/

I’m now using the attached patch, which causes the delete() method of the 
Photologue ImageModel to delete the image. This may well be too naive, but at 
least the tests pass now.

I noticed that Watermark also has an ImageField, so it’ll probably need a 
custom delete method too, but I don’t know your code well enough to 
anticipate any problems this may cause.

Have fun,
Telofy

Original issue reported on code.google.com by tel...@gmail.com on 27 Mar 2011 at 3:38

Attachments:

GoogleCodeExporter commented 9 years ago
See issue #9 on Github repository.

Original comment by richardb...@gmail.com on 12 Aug 2012 at 10:20