def dispatch(self, request, *args, **kwargs): if not is_module_image_installed(): data = { 'error': _("ImproperlyConfigured: Neither Pillow nor PIL could be imported: No module named 'Image'"), } return HttpResponse(json.dumps(data), content_type='application/json') return super(RedactorUploadView, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): try: self.tax_id = request.POST["tax"] except: self.tax_id = None if request.method == "POST" and request.is_ajax(): if not is_module_image_installed(): data = { "error": _( "ImproperlyConfigured: Neither Pillow nor PIL could be imported: No module named 'Image'" ) } return JsonResponse(data) return super(UploadView, self).dispatch(request, *args, **kwargs) else: raise Http404("Page not found")