Django:国家/地区下拉列表? [英] Django: Country drop down list?
本文介绍了Django:国家/地区下拉列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一张地址信息表格.字段之一是针对地址国家/地区.当前,这只是一个文本框.我想要一个(ISO 3166国家的)下拉列表.我是django新手,所以我还没有使用Django Select小部件.什么是这样做的好方法?
I have a form for address information. One of the fields is for the address country. Currently this is just a textbox. I would like a drop down list (of ISO 3166 countries) for this. I'm a django newbie so I haven't even used a Django Select widget yet. What is a good way to do this?
将选择的内容硬编码到某处的文件中?把它们放进数据库吗?在模板中?
Hard-code the choices in a file somewhere? Put them in the database? In the template?
推荐答案
from django_countries.fields import CountryField
class Foo(models.Model):
country = CountryField()
这篇关于Django:国家/地区下拉列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文