title: How to show select field with pre-selected data using django forms?
body: <p>I've a django Form with 2 choices (yes and no), on my &quot;create page&quot; i can render the <code>select</code> field to save the data and it works just fine, when i try to use on the &quot;edit page&quot; the value is not pre-selected with the current value, how can i make the current value <code>selected</code> on the <code>select</code> input field?</p>
  <p>The form:</p>
  <pre><code>class MyForm(forms.ModelForm):
  
      choose = forms.BooleanField(
          required=False,
          widget=forms.Select(
              choices=[(1, 'Yes'), (0, 'No')],
              attrs={'class': 'form-control'}
          )
      )
  
      class Meta:
          model = MyModel
  </code></pre>
  <p>When i call the view to edit:</p>
  <pre><code>class MyUpdateView(
      LoginRequiredMixin,
      SuccessMessageMixin,
      UpdateView,
  ):
      model = MyModel
      form_class = MyForm
      template_name = &quot;my/template.html&quot;
      success_url = reverse_lazy('my-url')
      success_message = 'Updated!'
  
      def get_object(self, queryset=None):
          data = super(MyUpdateView, self).get_object()
          if not data.user == self.request.user:
              raise Http404
          
          # data.choose is False
  
          return data
  </code></pre>
  <p>The <code>HTML</code> input will be always &quot;1&quot; (Yes) even tough the current value is &quot;0&quot; (No)</p>
  <p>The HTML:</p>
  <pre><code>{{ form.choose }}
  </code></pre>
  <p>The Model:</p>
  <pre><code>class MyModel(models.Model):
  
      choose = models.BooleanField(
          default=False,
          verbose_name='Cumulativo'
      )
  </code></pre>