3

I have the following entities. When I do api/event/1, I get the invitation included, but not the invitationResponses. If, and how, is this possible to achieve? When I do api/invitation/1 the invitationResponses are included.

class Person(db.Model):
    id = db.Column(db.Integer, primary_key = True)
    name = db.Column(db.String(64), index = True)
    owner = db.Column(db.Integer, db.ForeignKey('user.id'))
    description = db.Column(db.String(128))
    start = db.Column(db.DateTime)
    end = db.Column(db.DateTime)
    invitation = db.relationship('Invitation', uselist=False, backref =      db.backref('event', uselist=False))


class Invitation(db.Model):
    id = db.Column(db.Integer, primary_key = True)
    event_id = db.Column(db.Integer, db.ForeignKey('event.id'))
    sent = db.Column(db.DateTime)
    expires = db.Column(db.DateTime)
    invitationResponses = db.relationship('InvitationResponse', backref = db.backref('invitation', uselist=False))


class InvitationResponse(db.Model):
    id = db.Column(db.Integer, primary_key = True)
    invitation_id = db.Column(db.Integer, db.ForeignKey('invitation.id'))
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    attending = db.Column(db.Boolean)
vivekagr
  • 1,786
  • 15
  • 23
user713821
  • 349
  • 5
  • 14
  • 1
    Can you clarify your model please : Person has a relationship invitation, which sets a backref name event (???) in Invitation. Did you forget to show an Event class ? Can you provide the create_api signature for your /api/event end-point ? – TonyMoutaux Apr 15 '14 at 06:32
  • See the accepted answer for this question: http://stackoverflow.com/questions/22707223/flask-sqlalchemy-and-flask-restless-not-fetching-grandchildren – David Arnold Nov 28 '14 at 07:23

0 Answers0