isinstance(value, int) или type(value) == int
def check_exception(int_val:int) -> str | int:
try:
int(int_val)
except ValueError:
return 'Это не число'
return int_val
import uuid
import os
def get_file_path(instance, filename):
ext = filename.split('.')[-1]
filename = f'{uuid.uuid4()}.{ext}'
return os.path.join('folder_path', filename) # folder_path - нужная папка (article, по идее можно вытянуть из instance)
...
...upload_to=get_file_path