Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ImageUploadForm(forms.Form):
- url = forms.URLField(label='Ссылка', required=False)
- file_input = forms.FileField(label='Файл', required=False)
- #image_hash = forms.CharField(widget=forms.HiddenInput(), required=False)
- def clean(self):
- cleaned_data = super().clean()
- url = cleaned_data.get("url")
- file_input = cleaned_data.get("file_input")
- if url and file_input:
- raise forms.ValidationError('Выберите только один варинат')
- if url is '' and file_input is None:
- raise forms.ValidationError('Выберите хотя бы один вариант')
- return cleaned_data
- def clean_image_hash(self):
- data = self.cleaned_data['image_hash']
- print(self.file_input)
- instance = UploadedImage
- #raise forms.ValidationError("hash not unique"")
- return data
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement