我已经搜索了此文件,通常人们会遇到身份问题。我不认为这条路线应该上课吗?但是我已经尝试过了,并且得到了同样的错误:
TypeError: __init__() takes exactly 1 argument (2 given)
class entry(db.Model):
id = db.Column(db.Integer, primary_key=True)
url = db.Column(db.String(100), unique=True, nullable=False)
def __repr__(self):
return '<entry %r>' % self.url
@app.route('/new', methods = ['POST'])
def new():
if request.method == 'POST':
if not request.args.get('url'):
flash('Please provide at least a url', 'error')
else:
entry2 = entry("hey") #error on this line, I put "hey" just to debug
db.session.add(entry2)
db.session.commit()
flash('Record was successfully added')
return redirect(url_for('show_all'))
return render_template('index2.html')
完全错误:
127.0.0.1 - - [10/Feb/2019 13:27:14] "POST /new?url=http://google.com
HTTP/1.1" 500 -
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/flask/app.py", line 2309, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/lib/python2.7/site-packages/flask/app.py", line 2295, in wsgi_app
response = self.handle_exception(e)
File "/usr/lib/python2.7/site-packages/flask/app.py", line 1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python2.7/site-packages/flask/app.py", line 2292, in wsgi_app
response = self.full_dispatch_request()
File "/usr/lib/python2.7/site-packages/flask/app.py", line 1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/lib/python2.7/site-packages/flask/app.py", line 1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/python2.7/site-packages/flask/app.py", line 1813, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib/python2.7/site-packages/flask/app.py", line 1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/dk9/code/prj/app2.py", line 41, in new
entry2 = entry("hey")
TypeError: __init__() takes exactly 1 argument (2 given)
答案 0 :(得分:0)
您不应在您的输入模型中覆盖print (df[df.index.weekday < 5])
方法。完全删除该方法。
修改
模型仅需要关键字参数。所以你应该这样做:
__init__