I would not make this a reference fields. I would make it a IS_IN_SET(...) field. This is because possible nationalities do not change very often and are definitively not changed by the user.
On Tuesday, 9 February 2016 05:34:29 UTC-6, xmarx wrote: > > db.define_table('Person', > Field('last_name', 'string'), > Field('name', 'string'), > Field('telephone', 'string'), > Field('email', 'string'), > Field('nationality','reference Nationalities',default=1), > format= '%(last_name)s,%(name)s ' > ) > > default=the id of USA in Nationalities table > > > > 9 Şubat 2016 Salı 04:35:41 UTC+2 tarihinde Winter Kryz yazdı: >> >> Hello everybody, >> >> I am new in web2py, I have 2 tables called 'Nationalities' and 'Person' >> >> db.define_table('Nationalities', >> Field('description', 'string'), >> common_filter = lambda query:db.Nationalities.description >> != 'United States', >> format='%(description)s' >> ) >> >> db.define_table('Person', >> Field('last_name', 'string'), >> Field('name', 'string'), >> Field('telephone', 'string'), >> Field('email', 'string'), >> Field('nationality','reference >> Nationalities',requires=IS_IN_DB(db(db.Nationalities.description), >> 'Nationalities.description', zero=T('United States'))), >> format= '%(last_name)s,%(name)s ' >> ) >> in 'Nationalities', I have listed all the countries of world and what I >> get is a dropdown list filled with them >> Now what I want to do is to display a particular country, let's say >> 'United States', at top to be ID 0 in my dropdownlist so when somebody >> fills the form the list shows 'United States' by default. I tried to do a >> query that shows all the countries except US in the list and then set 'US' >> as Zero but of course it didn't work because it says that the value that >> zero has it doesn't exist on the database. >> Please, I need some help because I'm stuck on this. >> Thanks! >> > -- 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.