[SQLObject] Filtering selections via foreign keys
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Jason H. <jas...@gm...> - 2011-02-16 06:20:40
|
I'm trying to filter a selection from one table by looking up a referenced value in another table. An example is probably the easiest explanation: ---- class DocumentType (SQLObject) : """ What type the document is assigned to. """ dbType = StringCol() class Document (SQLObject) : """ Location of stored documents """ dbPath = StringCol() dbDocumentType = ForeignKey('DocumentType') def DocumentSearch(text, type=None): # initial query with text docs = dbase.dbase.SVNDocument.select(...) if type: docs.filter(...) return list(docs) ---- The "docs.filter(...): is where I want to allow only those Documents whose dbDocumentType refers to the DocumentType with dbType == type. I know this must be simple, but it's been a while since I used SQLObject and I just can't see it. Cheers, Jason |