Exemple #1
0
    def perform_search(self):
        """
        Perform a search using the parameters bound to this form.

        :throws ValidationError: If the form doesn't pass validation.
        """
        if not self.is_valid():
            raise ValidationError('Form must be valid to perform search.')

        return search_videos(
            query=self.cleaned_data['query'],
            fields=AUTOCOMPLETE_FIELDS.get(self.cleaned_data['field'], None),
            region=self.cleaned_data['region'],
            sort=self.cleaned_data['sort'],
        )