1👍
✅
it’s cause you cannot save encrypted(bytes) to model
try this
from django.core.files.base import ContentFile
for index, file in enumerate(files):
f = Fernet(settings.F_KEY)
pdf = file.read()
encrypted = f.encrypt(pdf)
content_file = ContentFile(encrypted, name=your_filename)
PDF_File.objects.create(
acct = a,
pdf = content_file
)
ref from here https://docs.djangoproject.com/en/4.0/topics/http/file-uploads/
Source:stackexchange.com