Re: [web2py] Re: Referencing another table

2016-10-15 Thread Val K
If you want to have strict DB-constraints, you can: db.define_table('barcode', Field('code', type='string', unique=True, notnull=True), # *consider just 'code', not 'barcode'* - it's necessary to prevent possible hard-to-catch bugs during SQLFORMs processing

Re: [web2py] Re: Referencing another table

2016-10-15 Thread 黄祥
i think it's can be done by record representation format, either in table format or in requires validation format representation. (the table bursary_entries just save the id for that refered to bursary_users, but it will shown the barcode, if you set the format correctly either in table format

Re: [web2py] Re: Referencing another table

2016-10-15 Thread vValentine1337
Ah okay. It should only be done via. A validated form anyway but I see the potential risk. Is the other option to set the barcode as the PK in my bursary_users table and 'reference' it? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (S

[web2py] Re: Referencing another table

2016-10-15 Thread Val K
Keep in mind, that 'reference ' - realized at DB-level as FK-constraint, web2py allows to define reference to PK only (you try to refer to not-PK field) requires=... - just web2py validator and has no effect on underlying DB and there isn't an autovalidation of DB manipulation from code

[web2py] Re: Referencing another table

2016-10-15 Thread James Booth
Okay, that seems to work fine, I guess I just tried to implement into incorrectly. Thanks for your help! -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) ---

[web2py] Re: Referencing another table

2016-10-15 Thread James Booth
How can I make the 'barcode' field in bursary_entries reference/depend upon a 'barcode' entry in bursary_users? Do I just have to alter my field to: type='text', requires=IS_IN_DB(db,'bursary_users.barcode) I was trying to make sense of what was needed here and I thought 'requires' was the best

[web2py] Re: Referencing another table

2016-10-14 Thread Val K
'reference bursary_users' and requires = [IS_IN_DB(db, 'bursary_users .barcode')] - I think, that it's mutually exclusive requirements 'reference bursary_users' == requires = IS_IN_DB(db, 'bursary_users.*id*') On Friday, October 14, 2016 at 6:21:38 PM UTC+3, James Booth wrote: > > Hey gu