模板层
1、后端向前端传递参数的两种方式: from app01 import views urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^index/',views.index), ] def index(request): n=6969 #以字典的形式通过key、value方式传递n变量名的值 return render(request,'index.html',{'n':n}) # 传递当前函数中定义的所有参数return render(request,'index.html',locals()) <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script> <script src="https://cdn.bootcss.com/twitter-bootstrap/3.4.1/js/bootstrap.min.js"></script> <link href="https://cdn.bootcss.com/twitter-bootstrap/3.4.1