backend/passfinder/utils/zip.py

16 lines
343 B
Python
Raw Normal View History

2023-05-18 20:25:22 +03:00
import zipfile
from django import forms
from .validators import validate_zip
class ZipfileField(forms.FileField):
file_validators = [validate_zip]
def to_python(self, value):
value = super().to_python(value)
for validator in self.file_validators:
validator(value)
return zipfile.ZipFile(value)