【发布时间】:2011-03-22 01:04:42
【问题描述】:
问题详情: 1] 我的模型如下所示
class UserReportedData(db.Model):
#country selected by the user, this will also populate the drop down list on the html page
country = db.StringProperty( choices=['Afghanistan','Aring land'])
#city selected by the user
city = db.StringProperty()
#date and time when the user reported the site to be down
date = db.DateTimeProperty(auto_now_add=True)
2] 这个模型有一个国家,它是html页面中的一个下拉列表和城市,它是当前html页面中的一个文本字段
模型的形式如下:
class UserReportedDataForm(djangoforms.ModelForm):
class Meta:
#mechanism to get the users country and city
geoiplocator_instance = GeoIpLocator()
city_country_dictionary=geoiplocator_instance.get_country_city_dictionary()
users_country_name = city_country_dictionary['country_name']
users_city = city_country_dictionary['city']
#using the model with the default country being users conutry and default city being users city
model = UserReportedData(default={'country':users_country_name})
3] 类 geoiplocator 用于查找用户国家和城市。
问题:
1] 我希望国家/地区下拉列表显示变量“users_country_name”中的用户国家/地区 以及显示用户城市的城市文本字段,在变量“users_city”中
谢谢,
【问题讨论】:
标签: python django google-app-engine django-forms