I tried to save the project reviewer using below, and the select field shows correctly:
# Query the user with Role.id == 4 as reviewer def reviewer_choices(): return User.query.join(User.roles).filter(Role.id == 4)
However, when I tried to save it, an error occurred:
InterfaceError: (sqlite3.InterfaceError) Error binding parameter 8 - probably unsupported type. [SQL: u'INSERT INTO project(...reviewer...)VALUES(...<__main__.User object at 0x00000000048E89E8>...) InterfaceError: (sqlite3.InterfaceError) Error binding parameter 8 - probably unsupported type. [SQL: u'INSERT INTO project(...reviewer...)VALUES(...<__main__.User object at 0x00000000048E89E8>...) .
And I noticed that the reviewer is an object, something like: <__main__.User object at 0x00000000048E89E8> . So, what is the correct reviewer data type so I can save it to the database? I am currently using:
In the project class
class Project(db.Model):
In the project table
CREATE TABLE `project` (
And I also tried to define __repr__ and __str__ , but both did not work:
class User(db.Model, UserMixin): id = db.Column(db.Integer, primary_key=True) first_name = db.Column(db.String(255))
source share