16 lines
583 B
Python
16 lines
583 B
Python
![]() |
def imageValidate(value):
|
||
|
import os
|
||
|
from django.core.exceptions import ValidationError
|
||
|
ext = os.path.splitext(value.name)[1]
|
||
|
valid_extensions = ['.jpg', '.png', '.gif']
|
||
|
if not ext.lower() in valid_extensions:
|
||
|
raise ValidationError('Unsupported file extension.')
|
||
|
|
||
|
def videoValidate(value):
|
||
|
import os
|
||
|
from django.core.exceptions import ValidationError
|
||
|
ext = os.path.splitext(value.name)[1]
|
||
|
valid_extensions = ['.mp4', '.mkv', '.avi']
|
||
|
if not ext.lower() in valid_extensions:
|
||
|
raise ValidationError('Unsupported file extension.')
|