AttributeError: type object 'User' has no attribute '_query_cls'
问题 User.id was of type postgresql.UUID Message.sender_id was of type postgresql.UUID with foreignkey to User.id . Changed my type to sqlalchemy_util.UUIDType . I had a problem for serializing my foreign key so I set my own JSONEncoder Now everything is working properly except when creating a Message (other classes with the same configuration does not have the problem). test_message.py def test_create_message(client, db, admin_user, admin_headers): # test bad data data = { 'message': 'foobar',