Nowdays I study the web2py.
I met the problems for me only.
By the appadmin.py, the database was constructed.
Then at the 'state' , there are problemes in the CSV import.

db files

#
db.define_table('country',
                Field('name', unique=True),
                Field('iso'),
                Field('numcode')
                )

db.define_table('state',
                Field('country_iso',db.country),
                Field('subcountry_code','string'),
                Field('name','string'),
                Field('subcountry_level','string')
                )

db.country.name.requires = IS_NOT_IN_DB(db,db.country.name)
db.country.name.requires = IS_NOT_EMPTY()

db.state.name.requires = IS_NOT_EMPTY()
db.state.country_iso.requires = IS_IN_DB(db, db.country.iso,'%(iso)s')

and csv files

name,iso,numcode
Afghanistan,AF,4
Albania,AL,8
Algeria,DZ,12
American Samoa,AS,16
Andorra,AD,20
Angola,AO,24
Anguilla,AI,660
Antarctica,AQ,10
Antigua and Barbuda,AG,28
Argentina,AR,32
Armenia,AM,51
Aruba,AW,533
Australia,AU,36
Austria,AT,40
Azerbaijan,AZ,31
Bahamas,BS,44
Bahrain,BH,48
Bangladesh,BD,50
Barbados,BB,52
Belarus,BY,112
Belgium,BE,56
Belize,BZ,84
Benin,BJ,204
Bermuda,BM,60
Bhutan,BT,64


country_iso,subcountry_code,name,subcountry_level
AD,AN,Andorra la Vella,NULL
AD,CA,Canillo,NULL
AD,EE,Escaldes-Engordany,NULL
AD,EN,Encamp,NULL
AD,JL,Sant Julià de Lòria,NULL
AD,MA,La Massana,NULL
AD,OR,Ordino,NULL
AE,AJ,Ajman,NULL
AE,AZ,Abu Z¸aby [Abu Dhabi],NULL
AE,DU,Dubayy [Dubai],NULL
AE,FU,Al Fujayrah,NULL
AE,RK,Ras al Khaymah,NULL
AE,SH,Ash Shariqah [Sharjah],NULL
AE,UQ,Umm al Qaywayn,NULL
AF,BAL,Balkh,NULL
AF,BAM,Bamian,NULL
AF,BDG,Badghis,NULL
AF,BDS,Badakhshan,NULL
AF,BGL,Baghlan,NULL
AF,FRA,Farah,NULL

Which parts are modified for corrected input?

Reply via email to