How to load a database of countries in a web application
I am new to web application development, so sorry in advance if this question is too basic.
The following are the details of the question:
A] Platform being used -- google app engine with python, django.
B] Tutorial link being used -- http://code.google.com/appengine/articles/djangoforms.html
C] Question: In the application i am building, there is a drop down box which allows the user to select their country. Since the list of countries is above 200, i want to construct a database of t开发者_StackOverflowhe countries before the application loads.
Once this application is deployed, i dont want the database to get re-loaded again, since the entries are constant for all the users. How does one achieve this ?
thanks, Lance.
Set the countries as a constant list:
COUNTRIES=['United States', 'England'...]
In your model:
country=db.StringProperty(verbose_name='Country',required=False, choices=set(COUNTRIES))
Now when you load your model form the select will be auto-populated from your countries list.
Just use
<select>
<option></option>
</select>
Thanks Jean
精彩评论