Python Flask WTF从字段中保存而不在路由中列出所有request.froms

时间:2016-09-04 23:37:53

标签: python flask flask-sqlalchemy wtforms flask-wtforms

您希望将发布的信息保存到数据库中。我正在使用python flask,这是我尝试它的方式。

class SongBook(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    song_book = db.Column(db.String(80))
    title = db.Column(db.String(120))
    artist = db.Column(db.String(120))
    disc_number = db.Column(db.String(120))
    track_number = db.Column(db.String(120))



    def __init__(self, song_book, title, artist, disc_number, track_number):
        self.song_book = song_book  
        self.title = title
        self.artist = artist
        self.disc_number = disc_number
        self.track_number = track_number

当我尝试这个时,我得到这个错误:
TypeError:__ init __()需要6个参数(给定1个)

有关如何做到这一点的任何想法?

这是模型

TypeError: __init__() takes exactly 6 arguments (1 given)

Traceback (most recent call last)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 2000, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1991, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/usr/local/lib/python2.7/dist-packages/flask_restful/__init__.py", line 271, in error_router
return original_handler(e)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1567, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1988, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1641, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python2.7/dist-packages/flask_restful/__init__.py", line 271, in error_router
return original_handler(e)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1544, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1639, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1625, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/a/Desktop/ddtkaraoke.com/app.py", line 118, in add_new_song
new_song = SongBook()
TypeError: __init__() takes exactly 6 arguments (1 given)

追溯

-replace

0 个答案:

没有答案