Commits

Guilherme Gondim committed 6ce40bc

prevent error when bad formatted EXIF data

  • Participants
  • Parent commits a0dd6fa

Comments (0)

Files changed (1)

File galeria/models.py

         if not self.date_taken:
             exif_date = self.EXIF.get('EXIF DateTimeOriginal', None)
             if exif_date:
-                self.date_taken = datetime.strptime(str(exif_date), '%Y:%m:%d %H:%M:%S')
+                try:
+                    self.date_taken = datetime.strptime(str(exif_date), '%Y:%m:%d %H:%M:%S')
+                except ValueError:
+                    # In case of bad formatted EXIF date...
+                    pass
                 super(Picture, self).save(*args, **kwargs)
 
     def __unicode__(self):