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):
if self.poster:
path = self.poster.path
self.poster.delete()
if os.path.exists(path):
self.poster.delete()
else:
self.poster.name = None
else:
poster= self.path('poster.jpg')
path = os.path.abspath(os.path.join(settings.MEDIA_ROOT, poster))