0

在我看来,我已将我的代码指向 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>
4

1 回答 1

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 %}
于 2012-07-16T09:06:26.777 回答