diff --git a/combo/apps/dataviz/templates/combo/chartngcell_form.html b/combo/apps/dataviz/templates/combo/chartngcell_form.html
index aafc5394..b0717869 100644
--- a/combo/apps/dataviz/templates/combo/chartngcell_form.html
+++ b/combo/apps/dataviz/templates/combo/chartngcell_form.html
@@ -1,6 +1,6 @@
{{ form.as_p }}
-{% if cell.chart_type != "table" and cell.is_relevant %}
+{% if cell.cached_json and cell.chart_type != "table" and cell.is_relevant %}
diff --git a/combo/apps/dataviz/views.py b/combo/apps/dataviz/views.py
index 54d28314..9810d6ee 100644
--- a/combo/apps/dataviz/views.py
+++ b/combo/apps/dataviz/views.py
@@ -15,7 +15,7 @@
# along with this program. If not, see
.
from django.core.exceptions import PermissionDenied
-from django.http import HttpResponse
+from django.http import HttpResponse, Http404
from django.utils.translation import ugettext_lazy as _
from combo.utils import get_templated_url, requests
@@ -34,6 +34,8 @@ def dataviz_graph(request, *args, **kwargs):
raise PermissionDenied()
if not cell.is_visible(request.user):
raise PermissionDenied()
+ if not cell.cached_json:
+ raise Http404('misconfigured cell')
try:
chart = cell.get_chart(
width=int(request.GET.get('width', 0)) or None,
diff --git a/tests/test_dataviz.py b/tests/test_dataviz.py
index 648516ca..fa4c5abf 100644
--- a/tests/test_dataviz.py
+++ b/tests/test_dataviz.py
@@ -428,6 +428,14 @@ def test_chartng_cell_view(app, normal_user):
resp = app.get('/api/dataviz/graph/1/?width=400', status=200)
assert '>10.0%<' in resp.text
+ # cell with missing cached_json (probably after import and missing
+ # bijoe visualisation)
+ cell.chart_type = 'table'
+ cell.save()
+ ChartNgCell.objects.filter(id=cell.id).update(cached_json={})
+ resp = app.get('/')
+ assert 'warningnotice' in resp.text
+
def test_chartng_cell_manager(app, admin_user):
page = Page(title='One', slug='index')