无法使用pythoneve和evesqlalchemy发布相关字段

2024-04-27 12:32:50 发布

您现在位置:Python中文网/ 问答频道 /正文

当我不能添加新的元素时,我不能发布相关的设备

curl -X POST -H "Content-Type: application/json"  -d '{
  "reports": [1],
  "short_description": "test1",
  "code": "TEST"
}' "http://localhost:4000/devices"

我得到以下错误(服务器抛出500个错误)。有什么想法吗?在

数据库是sqlite,但我不认为它是相关的

谢谢

AttributeError: 'int' object has no attribute '_sa_instance_state'

SQL炼金术配置

^{pr2}$

伊芙

registerSchema('device')(Device)
registerSchema('report')(Report)



settings = {
    'DEBUG': True,
    'IF_MATCH': False,
    'ENFORCE_IF_MATCH': False,
    'SQLALCHEMY_DATABASE_URI': config.DATABASE_URI,
    'DOMAIN': {
        'devices': Device._eve_schema['device'],
        'reports': Report._eve_schema['report']
    }
}

settings['DOMAIN']['devices'].update({
    'resource_methods': ['GET', 'POST', 'DELETE'],
    'item_methods': ['GET', 'PATCH', 'DELETE']
})

app = Eve(validator=ValidatorSQL, data=SQL, settings=settings)

Tags: reportfalsesqlifsettingsdevicematch错误