Your reference is wrong -- instead of 'reference db.group_of_events', it
should be 'reference group_of_events.group_name'. But I'm not sure that
will work either -- as mentioned
here<http://web2py.com/books/default/chapter/29/6#Legacy-databases-and-keyed-tables>,
keyed tables can only reference other keyed tables (in your code, you have
a standard web2py table referencing a keyed table). There are other
limitations as well. Even if it's redundant, your tables should all include
auto-incrementing id fields.
Anthony
On Sunday, July 22, 2012 3:18:12 PM UTC-4, Alec Taylor wrote:
>
> Looking through my code I realised that I would be better served if I
> could lookup and reference by `group_name` instead of `id`.
>
> I have set `group_name` to:
> Field('group_name', notnull=True, requires=[IS_SLUG(),
> IS_NOT_IN_DB(db, 'group_of_events.group_name')]),
>
> So it is perfect for a public key.
>
> Unfortunately when I set it, I get key errors (to double check, I
> dropped all records and refreshed; still got the error).
>
> Here is a 13 line test-case version: http://pastebin.com/8dLFb8QS
>
> What am I doing wrong; how do I make `group_name` public key?
>
> Thanks for all suggestions,
>
> Alec Taylor
>
--