Cannot fetch choices for multiple select from in django
<p>I've got a problems with fetching choices for multiple select form. I'm trying to get choices from couchdb. It's successfully printed out into console it:<br>
[[u'c6570a56173b637d66ba2a2e390271fe', u'Rambler'], [u'c6570a56173b637d66ba2a2e3902ad1f', u'BBC']]<br>
, but it doesn't appear in template. <br>
Here's my <strong>forms.py</strong>
</p>

<pre><code>sel = []


# FiltersForm is print out title, two select elements and an one required textinput's field
class FiltersForm(forms.Form):
    title = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'A title'}), label='Title')
    item = forms.ChoiceField(widget=forms.Select(attrs={'class': 'selectpicker'}), required=False, label='If',
                             choices=items)
    action = forms.ChoiceField(widget=forms.Select(attrs={'class': 'selectpicker'}), required=False, label='is',
                               choices=actions)
    word = forms.CharField(widget=forms.TextInput(attrs={'placeholder': 'a word'}))
    link = forms.URLField(max_length=255, widget=forms.URLInput(attrs={'value': 'http://'}))
    source = forms.MultipleChoiceField(widget=forms.SelectMultiple(attrs={'class': 'selectpicker'}), choices=sel)

    def __init__(self, *args, **kwargs):
        request = kwargs.pop('request', None)
        response = request.db.view('subscriptions/source', key=str(request.user)).rows
        for item in response:
            sel.append([item.id, item.value['title']])
        print sel
        super(FiltersForm, self).__init__(*args, **kwargs)
</code></pre>

<p><strong>Instance of form in views.py</strong> <br></p>

<pre><code># Retrieving a FiltersForm
form = FiltersForm(request.POST or None, request=request)
</code></pre>

<p>What's wrong with my form? </p>

<p>You've defined a local variable called <code>sel</code> inside your <code>__init__</code> method, but that doesn't have anything to do with the variable with the same name at global level that you used to populate the form. You'd actually have to replace the choices with your new values inside that method:</p>

<pre><code>self.fields['source'].choices = sel
</code></pre>

python django couchdb