Hello Massimo, Thanks for the reply (and also for the YouTube videos on web2py - the first one is an awesome introduction to the framework)
Basically, on what I'm trying to do, the user will never input a form. He will upload a file, which I'll parse and I'll create the form from it. Maybe I can somehow add the "uniqueness" logic in there by checking first in the db if such data is already present or not, rather than a "requires" rule in the db model. Not sure what's best. Thanks, NiKAL Le jeudi 18 juin 2015 14:19:58 UTC+2, Massimo Di Pierro a écrit : > > There is a conceptual problem. You can specify the constraint using SQL > but when you input a form, how should the error be reported? > > The standard practice is to attach a validator to only one of the two > fields > > db.define_table('x', Field('a'),Field('b'),...) > db.x.b.requires = IS_NOT_IN_DB(db(db.x.a==request.vars.a), db.b) > > > On Thursday, 18 June 2015 06:25:07 UTC-5, nikalstu...@gmail.com > <javascript:> wrote: >> >> Hello, >> >> I'm hoping it's not a too stupid question as I'm new to web2py. >> >> I have a table which I fill with data about some games. >> Each game has an id but multiple players can possibly have played the >> same game. >> >> So I basically need to have the (game_id, player_id) couple to be unique, >> but not each of them separately (one user can play multiple games, and same >> game can be used for multiple users). >> >> Is there a way to specify that ? >> >> My table is currently like : >> db.define_table("table", >> Field("game_id"), >> Field("user_id", 'reference auth_user', >> default=auth.user_id), >> Field("player_name"), >> Field("start_date", type="datetime"), >> Field("duration_sec", type="integer"), >> Field("finish_place", type="integer"), >> ) >> >> Thanks in advance, >> NiKAL >> > -- 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) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.