在我的观看中,我已经将我的代码指向了login.html>但是就绪功能中的警报或者身体上的内容都没有在UI上看到。我在这里做错了什么
{% extends "base/base.html" %}
<script>
$(document).ready(function() {
alert('1');
});
</script>
some code here
some code here
some code here
some code here
some code here
some code here
<b>{{response_dict.yes}} testing and testing and testinf</b>
<b>{{a}}</b>
<form action="/logon/" method="post" name="myform">
{% csrf_token %}
<b>Username</b><input type="text" name="username" id="username"></input>
<br><b>Password</b><input type="password" name="password" id="password"></input>
<b></b><input type="submit" value="Submit"></input>
<img src="/media/img/hi.png" alt="Hi!" /> <!-- This is working dude -->
<img alt="Hi!" src="/opt/labs/lab_site/media/img/hi.png">
</form>
答案 0 :(得分:2)
扩展模板时,需要指定基本模板的哪个块将呈现此标记。只需将其添加到base/base.html
:
{% block login %}{% endblock %}
在应该呈现登录表单的位置,然后在login.html
中,您将拥有:
{% extends "base/base.html" %}
{% block login %}
<script>
$(document).ready(function() {
.....
<img src="/media/img/hi.png" alt="Hi!" /> <!-- This is working dude -->
<img alt="Hi!" src="/opt/labs/lab_site/media/img/hi.png">
</form>
{% endblock %}