title: How can I pass a parameter from the view into a modelForm in django?
body: <p>My goal here is to have the user upload a document but my program names the document automatically. Essentially, from the view I pass the name into the form, where that name is placed in the 'descriptions' field of my Document model. Thanks!</p>
  
  <p>Views.py</p>
  
  <pre><code>def testing(request):
  if request.method == 'POST':
      name = 'testing'
      form = DocumentForm(request.POST, request.FILES, description=name)
      if form.is_valid():
          form.save()
          return redirect('landing')
  else:
      form = DocumentForm()
  return render(request, 'testing.html', {
      'form': form
  })
  </code></pre>
  
  <p>forms.py </p>
  
  <pre><code>class DocumentForm(forms.ModelForm):
  def __init__(self, *args, **kwargs):
      description = kwargs.pop('description')
      super(DocumentForm,self).__init__(*args, **kwargs)
      self.fields['description'].initial = description
  
  class Meta:
      model = Document
      fields = ('description', 'document', )
  </code></pre>
  
  <p>models.py</p>
  
  <pre><code>class Document(models.Model):
      description = models.CharField(max_length=255, blank=True)
      document = models.FileField(upload_to='documents/')
      uploaded_at = models.DateTimeField(auto_now_add=True)
  </code></pre>