我正在嘗試學習Django和Javascript/jQuery的個人項目。我想用Flot繪製一些數據,我試圖獲得一個測試圖來呈現,但我似乎做錯了。Flot不在Django中渲染
在我的base.html
我有以下內容,包括jQuery和Flot在我的head
元素。
<script src="/site_media/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="/site_media/jquery.flot.min.js" type="text/javascript"></script>
在我inherit.html
:
{% extends 'base.html' %}
<script type="text/javascript">
alert('Im running!');
$.plot($("#flot-test"), [ [[0, 0], [1, 1]] ], { yaxis: {max: 1 } });
</script>
{% block title %}Detail View for {{ sched_name }}{% endblock %}
{% block content %}
<div id="status_bar">
<a href="/view_schedules/">{{ user.username }}'s Gradebooks</a>/<a href="/view_schedules/{{ schedule_slug }}/">{{ sched_name }}</a>
</div>
<div id="flot-test" style="width:600px;height:300px">
</div>
The rest concatenated
然而,當我呈現使用Django的開發頁面。服務器我沒有收到像我收到的警報和情節不渲染。我得到一個空白div到我指定的尺寸。當我真正在網頁瀏覽器中查看我的頁面源時,它甚至不顯示我上面包含的劇情腳本。我究竟做錯了什麼?
如果瀏覽'http:// localhost:8000/static_media/jquery-1.7.2.min.js'你得到了什麼?這聽起來像經典的靜態文件問題。 –
@BurhanKhalid當我去那裏時,我得到了我應該得到的jQuery代碼。 –