2012-08-31 92 views
0

我不確定這個問題是在Django還是HTML中,所以我包含了這兩個。這是我看到,當我點擊右鍵,選擇「查看源文件」的HTML:奇怪的html渲染異常。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    <link href="/static//CSS/postingformstyle.css" rel="stylesheet" type="text/css" /> 
</head> 

<body> 
<div style="width:100%;"> 

    <span class="posting_title">Original Work</span> 

    <form action="" method="post" class="base_form"> 
     <p><label for="id_title">Title:</label> <input type="text" name="title" id="id_title" /></p> 
     <input type="hidden" name="id">8</input> 
     <input type="submit" class="posting_button">Post</input> 
    </form> 
</div> 
</body> 
</html> 

這是我弄的,什麼似乎呈現,當我點擊谷歌瀏覽器檢查元素。你注意到所有的結束標籤在表單中缺失。

<html xmlns="http://www.w3.org/1999/xhtml"><head> 


    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> 
    <link type="text/css" rel="stylesheet" href="/static//CSS/postingformstyle.css"> 
</head><body> 
<div style="width: 100%;"> 

    <span class="posting_title">Original Work</span> 

    <form class="base_form" method="post" action=""> 
     <p><label for="id_title">Title:</label> <input type="text" id="id_title" name="title"></p> 
     <input type="hidden" name="id">8 
     <input type="submit" class="posting_button">Post 
    </form> 
</div> 
</body></html> 

這是CSS:

.posting_button { 
    display:block; 
    font-size:20px; 
    width:100%; 
} 
.posting_title { 
    text-align:center; 
    display:block; 
    color:black; 
    font-size:30px; 
    font-family:Arial, Helvetica, sans-serif; 
    margin: 2px 0 15px 0; 
} 
.base_form label { 
    font-size: 17px; 
    font-family: arial; 
    font-weight: bold; 
    display: block; 
} 
.base_form > p { 
    margin: 2px 0 5px 0; 
} 

這是Django的(問題是否存在):

模板:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    <link href="{{ STATIC_URL }}/CSS/postingformstyle.css" rel="stylesheet" type="text/css" /> 
</head> 

<body> 
<div style="width:100%;"> 

    <span class="posting_title">Original Work</span> 

    <form action="" method="post" class="base_form"> 
     {{ form.as_p }} 
     <input type="hidden" name="id">{{ id }}</input> 
     <input type="submit" class="posting_button">Post</input> 
    </form> 
</div> 
</body> 
</html> 

Views.py

def posting_story_ow(request): 
    if request.method == 'POST': 
     d = 12 
    return render_to_response('Posting/Forms/posting_post_ow.html', {'STATIC_URL':STATIC_URL, 'id' : request.GET['id'], 'alertnum': 0, 'form': post_ow}) 

回答