Darren
unread,Feb 29, 2012, 7:21:08 AM2/29/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to SQLElixir
Hi,
I have a simple 1:many table relationship (say, user, adresses), and I
can say thing like the following (syntax wrong, just psuedo code):
jack = User(name="Jack")
jack.addresess.append(Address(postcode=345)
jack.addresess.append(Address(postcode=1234))
Then working with jack, I can say things like
jack.adresses[0] and get the first appended item, and [-1] to get last
(not sure if this is guarateed), just like they were python lists
To find address with postcode=345, I have to
User.query.filter(....... messy filter to specify which user and post
code)
Is there a more natural (python) way where I can do a query on that
list of jack.adresses, say:
jack.adresses.query(postcode == 345)
or
jack.addresses.postcode[345]
Thanks
Darren