applegrew/django-select2 — pull request #70 by log0ymxm (2013-11-03 17:54:34+00:00)
Title: Allow select2 fields to be chained using the filter_by widget option

This allows someone to chain multiple in-page select2 fields.

In my use case, I'm filtering state by country, and city by state as the user selects.

country = CountryChoices(
label='Country',
widget=AutoHeavySelect2Widget(
select2_options={
'placeholder': u"Country"
}
))
state = StateChoices(
label='State',
widget=AutoHeavySelect2Widget(
filter_by={
'id': 'id_country',
'related_name': 'country'
},
select2_options={
'placeholder': u"State"
}
))
city = CityChoices(
label='City',
widget=AutoHeavySelect2Widget(
filter_by={
'id': 'id_state',
'related_name': 'region'
},
select2_options={
'placeholder': u"City"
}
))

Let me know if there is a cleaner way to integrate this option. Referencing the id seems like it could be improved. Maybe there's a better place to put these, rather than the widget.