- 论坛徽章:
- 0
|
本帖最后由 mirage_o 于 2011-04-01 10:34 编辑
我按照django book中写了一个表单模板,却不能在页面中显示,以下是代码:
forms.py
from django import forms;
TOPIC_CHOICES = (
('general','General enquiry'),
('bug','Bug report'),
('suggestion','Suggestion'),
)
class ContactForm(forms.Form):
topic = forms.ChoiceField(choices=TOPIC_CHOICES);
message = forms.CharField();
sender = forms.EmailField(required=False);
views.py
def contact(request):
return render_to_response('contact.html',{'form',ContactForm});
html:
<form action="." method="POST">
<table> {{form.as_table}} </table>
<p><input type="submit" value="Submit"></p>
</form>
请问应该怎么修改才能在页面中显示表单模板中的内容
我用的是django1.2.5版本,似乎没有newforms,是不是在这个版本中已经集成到了django.forms? |
|