-1
我的TextField表单在html页面中显示正常,但不是DecimalFields。 DecimalFields根本不显示。Flask wtforms DecimalField不显示在HTML中
我forms.py:
from flask.ext.wtf import Form
from wtforms import TextField, validators, IntegerField, DateField, BooleanField, DecimalField
class EnterPart(Form):
Description = TextField(label='label', description="description", validators=[validators.required()])
VendorCost = DecimalField(label='label',description="cost")
我application.py:
from flask import Flask, render_template, request, redirect, url_for
def index():
form = EnterPart(request.form)
return render_template('index.html', form=form)
我的index.html:
{% extends "base.html" %} {% import 'macros.html' as macros %}
{% block content %}
{{ form.hidden_tag() }}
{{ macros.render_field(form.Description, placeholder='Description', type='dbSerial', label_visible=false) }}
{{ macros.render_field(form.VendorCost, placeholder='Category', type='dbSerial', label_visible=false) }}
{% endblock %}
我已经从这里的教程建设: http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world
提前致谢。
什么'macros.render_field'吗? – reptilicus
它应该为引导标准渲染领域。但是你是对的,这就是问题出在哪里。使用教程中的代码,macros.html没有DecimalField的选项,这就是为什么它没有被渲染。 – Generacy