class Item(db.Model):
id = Column(Integer, primary_key=True)
title = Column(Text, unique=False)
field = relationship("Field")
class Field(db.Model):
id = Column(Integer, primary_key=True)
name = Column(Text, unique=False)
measurement = relationship("Measurement")
item_id = Column(Integer, ForeignKey('item.id'))
class Measurement(db.Model):
id = Column(Integer, primary_key=True)
name = Column(Text, unique=False)
field_id = Column(Integer, ForeignKey('field.id'))
api_manager = APIManager(app, flask_sqlalchemy_db=db)
api_manager.create_api(Item, methods=['GET', 'POST', 'DELETE', 'PUT'])
Ответ:
{
"num_results": 2,
"objects": [
{
"field": [
{
"id": 1,
"item_id": 1,
"name": "fild1"
},
{
"id": 2,
"field_id": 1,
"name": "fild2"
}
],
"id": 1,
"title": "mes#1"
},
{
"field": [
{
"id": 3,
"item_id": 2,
"name": "fildd1"
},
{
"id": 4,
"lab_id": 2,
"name": "fildd2"
}
],
"id": 2,
"title": "mes#2"
}
],
"page": 1,
"total_pages": 1
}
В Item'e Field, однако в Field нет Measurement. Я делаю что-то в корне не так?