Django DecimalField未显示
由于某些原因,当所有其他字段都显示时,它不会显示 在表单中.py我有Django DecimalField未显示,django,django-forms,form-fields,Django,Django Forms,Form Fields,由于某些原因,当所有其他字段都显示时,它不会显示 在表单中.py我有 class addonForm(Form): choices = [('true','true'),('false','false')] name = CharField() fixed = ChoiceField(choices=choices) depth = DecimalField() def myView(request): context = RequestContext(
class addonForm(Form):
choices = [('true','true'),('false','false')]
name = CharField()
fixed = ChoiceField(choices=choices)
depth = DecimalField()
def myView(request):
context = RequestContext(request)
form = addonForm()
context.update({'form':form})
return render_to_response('addonPage.html',context)
...
{{ form }}
...
在视图中.py我有
class addonForm(Form):
choices = [('true','true'),('false','false')]
name = CharField()
fixed = ChoiceField(choices=choices)
depth = DecimalField()
def myView(request):
context = RequestContext(request)
form = addonForm()
context.update({'form':form})
return render_to_response('addonPage.html',context)
...
{{ form }}
...
在模板addonPage.html中,我有
class addonForm(Form):
choices = [('true','true'),('false','false')]
name = CharField()
fixed = ChoiceField(choices=choices)
depth = DecimalField()
def myView(request):
context = RequestContext(request)
form = addonForm()
context.update({'form':form})
return render_to_response('addonPage.html',context)
...
{{ form }}
...
但在我的模板中,我只显示表单中的名称和固定元素。我不明白我做错了什么。呸,这正是八月男人所说的。我没有从django.forms显式导入字段,所以我猜它使用的是django.models版本 确保从
django.forms
导入的是DecimalField
,而不是django.models
。