set default value of row for foreign key

32 views
Skip to first unread message

lcham...@gmail.com

unread,
Jan 21, 2021, 8:49:57 AM1/21/21
to web2py-users

Hello ,
i have 2 tables like this :

Model

db.define_table('t_plasmids',
    Field('f_protein', type='string', comment="50 characters max",
          label=T('Protein')),
    Field('f_plasmid_name', type='string', comment="100 characters max",
          label=T('Plasmid Name')),
    migrate = True)


db.define_table('t_plasmids_details',
    Field('f_plasmid_id',db.t_plasmids),
    Field('f_genbankid', type='string', comment="50 characters max",
          label=T('GenBankID')),
    Field('f_protein_function', type='string', comment="50 characters max",
          label=T('Protein Function')),

     migrate = True)
     
-----------------------     
     
Controller

def plasmids():
    query=(db.t_plasmids.id>0)
    records=SQLFORM.grid(query=query,maxtextlength = 100,create=create, deletable=delete, \
    links = [lambda row: A('ADD details for plasmid id = ',_href=URL("default","show_plasmid_details",args=['new','t_plasmids_details']))], \
    links_in_grid=True, \
    user_signature=False)
    return dict(records=records)
    

-------------------------
   
in the view i would like click on "show_plasmid_details", and have the default value f_plasmid_id set with the default value row.id

Is it possible

Thank you very much
Reply all
Reply to author
Forward
0 new messages