title: Getting the cleaned_data of a CharField with Choice from Django
body: <p>I'm trying to retrieve the data of a form that belongs to a CharField that uses choice in Django. </p>
  
  <p>I have the following <strong><em>models.py</em></strong>:</p>
  
  <pre><code>class Transaccion(models.Model):
      ref = models.CharField(max_length=20, primary_key=True)
      fecha = models.DateField(default=timezone.now)
      usua = models.ForeignKey(User, on_delete=models.CASCADE, blank=True, null=True)
      monto = models.FloatField(max_length=50, blank=True, null=True)
      TYPE_TRANS = (
          ('d', 'Debito'),
          ('c', 'Credito'),
      )
      tipo = models.CharField(max_length=1, choices=TYPE_TRANS)
      LOAN_STATUS = (
          ('a', 'Aprobada'),
          ('e', 'Pendiente'),
          ('c', 'Rechazada'),
      )
      estado = models.CharField(max_length=1, choices=LOAN_STATUS, blank=True, default='e')
      TYPE_BANCO = (
          ('BBVA', 'Bco BBVA Provincial'),
          ('BOD', 'Banco Occidental de Descuento'),
          ('MER','Bco Mercantil')
      )
      bco = models.CharField(max_length=4, choices=TYPE_BANCO, blank=True)
  </code></pre>
  
  <p>The following <strong><em>forms.py</em></strong>:</p>
  
  <pre><code>class GestionarTransaccionForm(forms.ModelForm):
      class Meta:
          model = Transaccion
  
          fields = [
              'usua',
              'fecha',
              'bco',
              'ref',
              'monto',
              'tipo',
              'estado',
          ]
          widgets={
              'usua': forms.TextInput(attrs={'class': 'form-control', 'readonly': True}),
              'fecha': forms.TextInput(attrs={'class': 'form-control', 'readonly': True}),
              'bco': forms.Select(attrs={'class': 'form-control', 'readonly': True}),
              'ref': forms.TextInput(attrs={'class': 'form-control', 'readonly': True}),
              'monto': forms.TextInput(attrs={'class': 'form-contol', 'readonly': True}),
              'tipo': forms.Select(attrs={'class': 'form-control', 'readonly': True}),
              'estado': forms.Select(attrs={'class': 'form-control'}),
          }
  
      def __init__(self, *args, **kwargs):
          super().__init__(*args, **kwargs)
          self.fields['ref'].disabled = True
          self.fields['fecha'].disabled = True
          self.fields['usua'].disabled = True
          self.fields['monto'].disabled = True
          self.fields['tipo'].disabled = True
          self.fields['bco'].disabled = True
  </code></pre>
  
  <p>And this <strong><em>views.py</em></strong>:</p>
  
  <pre><code>class GestionarTransaccion(UpdateView):
      model = Transaccion
      form_class = GestionarTransaccionForm
      template_name = "administrador/gestionarT.html"
      success_url = reverse_lazy('transManager')
  
      def form_valid(self, form):
          instance = form.save(commit=False)
          u = User()
          if form.cleaned_data['estado']=='Aprobado':
              if form.cleaned_data['tipo']=='Credito':
                  u.incrementarSaldo(form.cleaned_data['monto'], form.cleaned_data['usua']) 
              elif form.cleaned_data['tipo']=='Debito':
                  u.disminuirSaldo(form.cleaned_data['monto'], form.cleaned_data['usua'])
          return super().form_valid(form)
  </code></pre>
  
  <p>The problem appears when dealing with this little code snippet:</p>
  
  <pre><code>        if form.cleaned_data['estado']=='Aprobado':
              if form.cleaned_data['tipo']=='Credito':
                  u.incrementarSaldo(form.cleaned_data['monto'], form.cleaned_data['usua']) 
              elif form.cleaned_data['tipo']=='Debito':
                  u.disminuirSaldo(form.cleaned_data['monto'], form.cleaned_data['usua'])
  </code></pre>
  
  <p>It calls for a couple methods inside of the User <em>(methods that do work, because I tried them without the conditional and worked flawlessly)</em>, but it does nothing with the conditional. I get suspicious that the <strong>cleaned_data</strong> format isn't what I think it is, but trying with the code ('d' instead of 'Debito') does nothing at all. Any idea on how to work with this?</p>
  
  <p><strong><em>EDIT</em></strong></p>
  
  <p>Changed to</p>
  
  <pre><code>        if form.cleaned_data['estado']=='a':
              if form.cleaned_data['tipo']=='c':
                  u.incrementarSaldo(form.cleaned_data['monto'], form.cleaned_data['usua']) 
              elif form.cleaned_data['tipo']=='d':
                  u.disminuirSaldo(form.cleaned_data['monto'], form.cleaned_data['usua'])
  </code></pre>
  
  <p>And it magically worked, although I tried that and didn't work before.</p>