mirror of
https://github.com/task-17-lct/backend.git
synced 2024-11-24 02:13:46 +03:00
16 lines
343 B
Python
16 lines
343 B
Python
|
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)
|