check if it poster exists

This commit is contained in:
j 2011-10-25 09:39:33 +02:00
parent 38abce6033
commit d11eacd8ba

View file

@ -893,7 +893,10 @@ class Item(models.Model):
def delete_poster(self): def delete_poster(self):
if self.poster: if self.poster:
path = self.poster.path path = self.poster.path
self.poster.delete() if os.path.exists(path):
self.poster.delete()
else:
self.poster.name = None
else: else:
poster= self.path('poster.jpg') poster= self.path('poster.jpg')
path = os.path.abspath(os.path.join(settings.MEDIA_ROOT, poster)) path = os.path.abspath(os.path.join(settings.MEDIA_ROOT, poster))