title: Django: forms.ChoiceField, overriding forms __init__
body: <p>I am trying to implement a forms.ChoiceField() with values from a view.
  I already can do it if I declare the choices in the forms.py, but that's not what I need.</p>
  
  <p>views.py:</p>
  
  <pre><code>def add_crime(request):
          values = [('1','um'),('2','dois'),('3','tres')]
          if request.method == 'POST':
              form = AddCrimeForm(request.POST, values)
              if form.is_valid():
                  # do stuff
                  return redirect('show_crime')
          else:
              form = AddCrimeForm(request.GET)
          return render(request, 'add_crime.html', {'form': form})
  </code></pre>
  
  <p>forms.py:</p>
  
  <pre><code>class AddCrimeForm(forms.Form):
      tests = forms.ChoiceField()
      def __init__(self, testList, args, **kwargs):
          self.testList = testList
          super(AddCrimeForm,self).__init__(*args, **kwargs)  # testList not in args!
          self.fields['tests'].widget = forms.CheckboxSelectMultiple()
          self.fields['tests'].choices = self.testList
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>AttributeError: 'tuple' object has no attribute 'get'
  </code></pre>
  
  <p>From the feedback, do I have to implement another <code>__init__</code> with one argument in forms.py? That's what I would try in Java.</p>
  
  <p>My final goal is to implement two ChoiceField and the second one would depend from the first one. Is there a better way?</p>