Do you mean that you have a recursive sql request?
Or you want to rename the default id field name for PK?
In the second case :
Field('ouid','id')
does the tricks...
Richard
On Thu, Nov 25, 2010 at 9:16 AM, Johann Spies <[email protected]>wrote:
> I want to use a foreign key which does not refer to the id-field of another
> record
>
> eg.
>
>
>
> db.define_table('journal',
> Field('ouid','integer'),
> Field('journal',unique=True),
> Field('issn', length=10),
> Field('notes', type='text'),
> signature,
> format=lambda r: r.journal
> )
>
> db.define_table('article',
> Field('ouid', type='integer'),
> Field('journal', type='string', length=255),
> Field('journal_id', db.journal, requires =
> IS_IN_DB(db,'journal.ouid')),
> Field('volume', type='string', length=20))
>
> I want 'journal_id' in 'article' to refer to 'ouid' in 'journal' and not
> to 'id'. How do I do it in web2py.
>
> I am using postgresql as backend. I can define the foreign key in
> Postgresql but how do I do it through DAL?
>
> Regards
> Johann
>
> --
> May grace and peace be yours in abundance through the full knowledge of
> God and of Jesus our Lord! His divine power has given us everything we need
> for life and godliness through the full knowledge of the one who called us
> by his own glory and excellence.
> 2 Pet. 1:2b,3a
>
>