I am trying to embed a Bokeh plot in a Django site that has a download button on it. I use the example here here as a starting point, and then adding the implementation instructions from here , I used it need-a-minimal-django-file-upload-example/for_django_1.8, and it works as intended. Then I changed the following files, but I get the following error:
ImportError: no module named 'myapp'
Here you can see my directory structure and three files modified / added:

If you cannot upload the image, here:
.
βββ myproject
βββ db.sqlite3
βββ manage.py
βββ media
β βββ documents
β βββ 2016
β βββ 01
β βββ 12
β β βββ silico_0_truth_filtered_ptps.csv
β βββ 15
β βββ silico_0_truth_filtered_ptps.csv
βββ myproject
βββ __init__.py
βββ myapp
β βββ admin.py
β βββ forms.py
β βββ __init__.py
β βββ migrations
β β βββ 0001_initial.py
β β βββ __init__.py
β β βββ __pycache__
β β βββ 0001_initial.cpython-35.pyc
β β βββ __init__.cpython-35.pyc
β βββ models.py
β βββ __pycache__
β β βββ admin.cpython-34.pyc
β β βββ admin.cpython-35.pyc
β β βββ forms.cpython-35.pyc
β β βββ __init__.cpython-34.pyc
β β βββ __init__.cpython-35.pyc
β β βββ models.cpython-34.pyc
β β βββ models.cpython-35.pyc
β β βββ urls.cpython-35.pyc
β β βββ views.cpython-35.pyc
β βββ templates
β β βββ list.html
β β βββ simple_chart.html
β βββ tests.py
β βββ urls.py
β βββ views.py
βββ __pycache__
β βββ __init__.cpython-34.pyc
β βββ __init__.cpython-35.pyc
β βββ settings.cpython-34.pyc
β βββ settings.cpython-35.pyc
β βββ urls.cpython-35.pyc
β βββ wsgi.cpython-35.pyc
βββ settings.py
βββ urls.py
βββ wsgi.py
Here templates/simple_chart.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Experiment with Bokeh</title>
<script src="http://cdn.pydata.org/bokeh/release/bokeh-0.8.1.min.js"></script>
<link rel="stylesheet" href="http://cdn.pydata.org/bokeh/release/bokeh-0.8.1.min.css">
</head>
<body>
{{the_div|safe}}
{{the_script|safe}}
</body>
</html>
Here myapp/urls.py(An error occurs here. I do not understand why the import cannot be allowed):
from django.conf.urls import patterns, url
from myapp.views import simple_chart
urlpatterns = patterns('myproject.myapp.views',
url(r'^list/$', 'list', name='list'),
url(r'^simple_chart/$', simple_chart, name="simple_chart"),
)
Here myapp/views.py:
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse
from myproject.myapp.models import Document
from myproject.myapp.forms import DocumentForm
from django.shortcuts import render
from bokeh.plotting import figure
from bokeh.resources import CDN
from bokeh.embed import components
def list(request):
if request.method == 'POST':
form = DocumentForm(request.POST, request.FILES)
if form.is_valid():
newdoc = Document(docfile=request.FILES['docfile'])
newdoc.save()
return HttpResponseRedirect(reverse('myproject.myapp.views.list'))
else:
form = DocumentForm()
documents = Document.objects.all()
return render_to_response(
'list.html',
{'documents': documents, 'form': form},
context_instance=RequestContext(request)
)
def simple_chart(request):
plot = figure()
plot.circle([1,2], [3,4])
script, div = components(plot, CDN)
return render(request, "simple_chart.html", {"the_script":script, "the_div":div})