add image to model
This commit is contained in:
parent
56773eea67
commit
12a8d1ec7e
@ -19,6 +19,7 @@ class BackgroundVideo(models.Model):
|
||||
validators=[FileExtensionValidator(allowed_extensions=["webm"])],
|
||||
blank=True, null=True
|
||||
)
|
||||
image = models.ImageField(upload_to='videos/images/', blank=True, null=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.mp4_file.name.split('.')[0]
|
||||
@ -32,5 +33,9 @@ class BackgroundVideo(models.Model):
|
||||
os.remove(self.mp4_file.path)
|
||||
except FileNotFoundError:
|
||||
error_logger.error(traceback.format_exc())
|
||||
try:
|
||||
os.remove(self.image.path)
|
||||
except FileNotFoundError:
|
||||
error_logger.error(traceback.format_exc())
|
||||
|
||||
super().delete(*args, **kwargs)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user