2012-07-16 194 views
0

在我的看法我已經指出我的代碼login.html>但就緒函數或內容,以便f的身體沒有在UI上看到的警報。我在這裏做錯了什麼django模板內容沒有顯示

{% 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> 

回答

1

當您擴展模板時,您需要指定您的基本模板的哪個塊將呈現此標記。在登錄表單應呈現的地方

{% block login %}{% endblock %} 

,然後在login.html你必須:只需添加到這個base/base.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 %} 
+0

我沒有understand..So我是猜想把你的代碼放在base.html中。什麼把這個html包含在login.html中的同一個塊中? – Rajeev 2012-07-16 09:24:31

+0

我應該在login.html頁面做什麼? – Rajeev 2012-07-16 09:26:58

+0

查看已更新的回答 – Tisho 2012-07-16 09:35:30