title: pass variable from view to form initial in django
body: <p>Sorry, I am new to django. I don't know how to do: #Main objective: read yaml file, pass the Resize variable from view to form, and set the form resize field to inital value. please help. thanks.</p>
  <p>#views</p>
  <pre><code>class preprocessing(FormView): video_para = read_yaml()
  
  Resize = video_para['Resize']
  
  def preprocessing_view(request):
  
  
      if request.method == 'POST':
          form = preprocessing_form(request.POST or None)
          if form.is_valid():
              new_form = form.save(commit=False)
              Resize_new = form.cleaned_data['Resize']
              new_form.Resize_new = form.cleaned_data['Resize']
              new_form.save()
  
      else:
          form = preprocessing_form()
      
      context= {
          'form': form,
          'Resize' : Resize
      }
      
      return render(request,'preprocessing.html', context)
  </code></pre>
  <p>#forms</p>
  <pre><code>class preproces
  
  sing_form(forms.ModelForm):
      
      def __init__(self, *args, **kwargs):
          self.Resize = kwargs.pop('Resize')
          super().__init__(*args, **kwargs)
      
      Resize = forms.BooleanField(initial=Resize)
      
      def save(self):
          Resize = self.Resize
      
      class Meta:   
          model= preprocessing_class
          fields= [&quot;Resize&quot;]
      
  </code></pre>