HristoTodorov / django-photologue

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

ImageModel Save Method Always sets date_take property to datatime.datetime.now #154

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create and save a photo with exif data embedding in the image itself
2.
3.

What is the expected output? What do you see instead?
The property date_taken should be set to the date created property or the EXIF 
DateTimeOriginal data.

Open shell, pull up latest photo and access photo.EXIF['EXIF DateTimeOriginal'] 
to verify discrepancy 

It always saves falls back to the default value

What version of the product are you using? On what operating system?
r405 lines 460 -469

Please provide any additional information below.
if you step through the code, you are trying to access self.EXIF in the save 
method of ImageModel. In the current Configuration self.EXIF always returns {} 
because the object has not been saved yet. Thus the fall back behavior is 
always 
followed. This is the same as trying to access self.pk before the object has 
been saved, it is a property that doesn't exist yet.

You would need to first save the object, the you would be able to run 
self.EXIF.get('EXIF DateTimeOriginal')

Original issue reported on code.google.com by e3satter...@gmail.com on 22 Mar 2010 at 4:10

GoogleCodeExporter commented 8 years ago
A more correct statement would be that the lines:
270 & 273 both fail on the initial save/creation of the photo object because 
self.image.path returns a path starting with the media root.

In this situation, the photo does not exist in that location. Only after the 
first save 
is complete will it be there. So the open() portion will always fail to find it.

Original comment by e3satter...@gmail.com on 22 Mar 2010 at 4:30

GoogleCodeExporter commented 8 years ago
this would correct the problem:
[FROM]
exif_date = self.EXIF.get('EXIF DateTimeOriginal', None)
[TO]
exif_date = EXIF.process_file(self.image.file).get('EXIF DateTimeOriginal', 
None)

Original comment by e3satter...@gmail.com on 22 Mar 2010 at 4:37