Django中调用base.html的功能是什么,如何在base.html中执行python代码,在运行时执行 [英] What is the function in Django that calls base.html and how can I see python code inside base.html execute at runtime
问题描述
我想我正在调用一个js函数,显示一个带有自定义python的calandar,但我不知道它在哪里,所以我可以调试它。这是对base.html中的js的调用
< script src =$ {url_static} js / jquery.ui .datepicker-ja.jstype =text / javascript>< / script>
< script src =$ {url_static} js / admin / jquery-ui.min.jstype =text / javascript>< / script>
< script type =text / javascript>
$(function(){$('。datepicker')。datepicker();});
< / script>
Python代码在服务器上执行。生成的html被发送到客户端。在你发布的代码中,{url_static}是被替换为实际的值,但可能不起作用,因为django模板寻找变量为 {{url_static}}
。注意双括号。
由于jquery未加载,您的datepicker不起作用。您可以查看渲染页面的源(或检查元素),并确认脚本src是否正确。
I'm not sure if its 2 questions, but I need to see the values of my python code being executed at runtime. Can anyone tell me how this works? Does the python get executed on the client side, and if so, how can I see its values like I can for my views classes in Eclipse? I think I'm calling a js function that shows a calandar with custom python, but I'm not sure where it is so I can debug it. this is the call to the js in base.html
<script src="${url_static}js/jquery.ui.datepicker-ja.js" type="text/javascript"></script>
<script src="${url_static}js/admin/jquery-ui.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){$('.datepicker').datepicker();});
</script>
Python code is executed on the server. The generated html is sent to the client. In the code you have posted {url_static} is meant to be replaced with the actual value, but probably doesn't work since django template looks for variables as {{ url_static }}
. Notice the double braces.
Your datepicker isn't working since jquery isn't loaded. You can view source (or inspect element) for your rendered page and confirm if the script src is correct.
这篇关于Django中调用base.html的功能是什么,如何在base.html中执行python代码,在运行时执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!