2012-12-08 80 views
0

當我把{}形式在一些模板,它呈現這樣的:Django的自定義表單呈現

<tr><th></th><td><input type="text" name="login" maxlength="10" /></td></tr> 
<tr><th></th><td><input type="text" name="email" /></td></tr> 
<tr><th></th><td><input type="text" name="password" maxlength="10" /></td></tr> 

但如果我不需要TR,TH,TD,p標籤?這就是我要的。

<input type="text" name="login" placeholder="Имя пользователя"/> 
<input type="email" name="email" placeholder="E-mail"/> 
<input type="password" name="password" placeholder="Пароль"/> 

回答

1

你目前看到的是form.as_table的輸出,它給出了你插入到一組標記中的tr元素的表現形式。您需要在django文檔中查看Customizing the form template,以使它們完全按照您希望它們執行的操作。該鏈接通過示例引導您完成。

只得到輸入控件,通過表單迭代,只有插入域本身:

<form action="" method="get"> 
    {% for field in form %} 
     {{ field }} 
    {% endfor %} 
</form>