AttributeError: объект UnboundField не имеет атрибута data (python Flask) Как решить эту проблему?

Код Python: (main_

… from flask import Flask, render_template, url_for,request,flash,redirect from formzxc import Amount from flask_sqlalchemy import SQLAlchemy app = Flask(__name__) app.config[‘SECRET_KEY’] = ‘8ed085d7c0aefb62c65e9d2154c3f377’ app.config[‘SQLALCHEMY_DATABASE_URI’] = ‘sqlite:/https://testing.db’ app.config[‘SQLALCHEMY_ECHO’] = True db = SQLAlchemy(app) class Category(db.Model): id = db.Column(db.Integer,primary_key = True) desc = db.Column(db.String(25),unique = True,nullable =False) amt = db.Column(db.Integer,nullable =False) def __repr__(self): return f»Category(‘{self.desc}’.'{self.amt}’)» @app.route(‘/’,methods = [‘GET’,’POST’]) #need to research more on the methods @app.route(‘/main’,methods = [‘GET’,’POST’]) def home(): form = Amount() #this is the amount FlaskForm imported if form.validate_on_submit(): #validation is true flash(f’Done liao’,’success’) #a message to put; put at homepage or prev page newpost = Category(desc =,amt ) ## db.session.add(newpost) db.session.commit() return redirect(url_for(‘home’)) #function else: flash(‘Shit!’,’danger’) return render_template(f’test.html’,form = form) if __name__ == ‘__main__’: ….

Код Python (для formzxc) из flask_wtf import FlaskForm из wtforms import StringField, PasswordField, SubmitField, BooleanField, IntegerField из wtforms.validators import DataRequired, Length, Email, EqualTo

class Amount(FlaskForm): purpose = StringField(‘Type:’, validators = [DataRequired(),Length(max =25)]) amount = IntegerField(‘Amount:’, validators = [DataRequired()]) submit = SubmitField(‘Submit!’)

Следует ли использовать вместо при вызове Category?   —  person DemonicAoi    schedule 30.12.2019

^ спасибо 4 тоже помощь   —  person DemonicAoi    schedule 30.12.2019


Стиль жизни - Здоровье!