-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