【发布时间】:2017-06-28 17:01:04
【问题描述】:
我使用 select2]1 和 django-countries 以便为用户提供可能国家/地区的下拉列表。我现在想(1)拆分下拉列表或(2)重新排列项目/国家的顺序,即:
目前我得到一个按字母顺序排列的列表:
- select country
- Afghanistan
- Albania
- Algeria
...
- Kenya
...
- Zimbabwe
我想要的是: (1)
- select country
- Germany
- Austria
- Switzerland
---------------------------
- Afghanistan
- Albania
- Algeria
...
- Kenya
...
- Zimbabwe
或 (2)
- select country
- Germany
- Austria
- Switzerland
- Afghanistan
- Albania
- Algeria
...
- Kenya
...
- Zimbabwe
这是我的 js:
$(document).ready(function () {
$("#id_nationality").select2({
default: 'Germany',
placeholder: 'select country'
});
});
我使用crispy-forms 进行表单渲染
【问题讨论】:
标签: python django select2 django-countries