Select a valid choice is not one of the available choices
<p>I'm new to Django. What i'm trying to do is to show some JSON response value which i converted into tuples to show in the choicefield of my Django form. </p>

<p>This is how i'm creating the tuples</p>

<pre><code>usernamelist = []
useremaillist = []
for userobject in userobjects:
    username = userobject['somevalue']
    email = userobject['somevalue']
    useremaillist.append(email)
    usernamelist.append(username)
user_tuple = zip(usernamelist,useremaillist)
</code></pre>

<p>This is my form</p>

<pre><code>class UserSelectForm(forms.Form):
    users = forms.ChoiceField(label="Select user")
</code></pre>

<p>Then in my views i'm trying to put all these names into drop down list</p>

<pre><code>selectform = UserSelectForm()
selectform.fields['users'].choices = user_tuple
</code></pre>

<p>its successfully showing but when i try to submit my form i'm getting Select a valid choice is not one of the available choices error.</p>

<p>This is where i'm trying to get the drop down selected value from submitted form</p>

<pre><code>if request.method == 'POST' and 'preview' in request.POST:
    selectform = UserSelectForm(request.POST)
    if selectform.is_valid():
        user_email = selectform.cleaned_data['users']
        print user_email
        return HttpResponseRedirect('/')
</code></pre>