I got the same issue today and solved it with some workaround.
Here is what my models look like:
class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
...
class Key(db.Model):
user_id = db.Column(db.Integer, db.ForeignKey('auth_user.id'))
user = db.relationship('User', backref=db.backref('keys', lazy='dynamic'))
...
Cause:
I got the same error message when querying users
. And I found that flask-restless is trying to query the related keys
for my users
and unfortunately, my key
table is empty and I got the error message.
Workaround:
Use include_columns or exclude_columns to exclude the keys
column when creating APIs:
api_mgr.create_api(User, include_columns = ['email', 'username'])
or:
api_mgr.create_api(User, exclude_columns = ['keys', 'SOME_OTHER_COLUMNS'])
You can check out if there is any related tables causing the problem. And if it is the cause, you can using include_columns or exclude_columns keyword arguments.