一.base.html
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="utf-8">
<title>Proyecto Demo</title>
<!-- Le styles -->
<link href="/media/bootstrap/css/bootstrap.css" rel="stylesheet">
<link href="/media/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
<script src="/media/js/jquery.js"></script>
<script src="/media/bootstrap/js/bootstrap.js"></script>
<style type="text/css">
body {
padding-top: 60px;
padding-bottom: 40px;
}
.sidebar-nav {
padding: 9px 0;
}
</style>
<script type="text/javascript">
$(document).on('ready',function(){
$.ajax({
type:"GET",
contentType:"application/json; charset=utf-8",
dateType:"json",
url:"/ws/productos/",
success:function(response){
var i = (response.length-1)-2;
for(i;i<=(response.length-1);i++){
$('#ProductosNuevos').append("<li>"+response[i].fields.nombre+"</li>");
}
}
});
});
</script>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container-fluid">
<a class="brand" href="{% url vista_principal %}">Proyecto Ventas </a>
{% if user.is_authenticated %}
<p class="navbar-text pull-right">
Logged in as {{ user.username }}
</p>
{% endif %}
<ul class="nav">
<li><a href="/productos/page/1/">Productos</a></li>
<li><a href="{% url vista_contacto %}">Contacto</a></li>
<li><a href="{% url vista_about %}">Acerca de ...</a></li>
{% if user.is_authenticated %}
<li><a href="{% url vista_logout %}"> Cerrar Sesion </a></li>
{% else %}
<li><a href="{% url vista_login %}"> Login </a></li>
{% endif %}
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span9">
<div class="hero-unit">
{% block content %}
{% endblock%}
</div>
</div><!--/span-->
<div class="span3">
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">Mi Carrito</li>
<br><p align="justify">
Carrito de Super
</p>
</ul>
</div><!--/.well -->
<div class="well sidebar-nav">
<ul class="nav nav-list" id="ProductosNuevos">
<li class="nav-header">Nuevos Productos</li>
</ul>
</div><!--/.well -->
<img src="/media/images/django.gif"/>
</div><!--/span-->
</div><!--/row-->
<hr>
<footer>
<p>© Open Project 2013 </p>
</footer>
</div><!--/.fluid-container-->
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
</body>
</html>
可以先把回复输出到控制台,在Firebug中调试
还可以查看JSON格式