[SQLObject] Re: defining 1 to many relationships
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Chris G. <ch...@il...> - 2004-02-23 22:09:20
|
>The images table contains a field called source_di which links to the di id field which is also the key for the di table. i defined the table classes like this: > > class Images(SQLObject): > _idName = 'uin' > _fromDatabase = True > sourceDi = ForeignKey('Di') > > class Di(SQLObject): > _fromDatabase = True > _idName = 'id' > Images = ForeignKey('Images') The problem is that a ForeignKey column gives you back one object, since it's for references to a single index in another table. So, when you access Images in Di, it ain't gunna work. You have to make Images = MultipleJoin('Images'). You may also have to go into SQL and rename the column in the Images table that references back to Di, although I'm not certain about this. I am a bit new to SQLObject myself. :) = Chris Gahan ============= (ch...@il...) |