title: How to bind an image to an edit form in Django?
body: <p>I have the following Model:</p>
  
  <pre><code>class Listing(models.Model):
      name = models.CharField(max_length=50, verbose_name="Title")
      images = models.ManyToManyField('Image')
  </code></pre>
  
  <p>, with the <code>ManyToManyField</code> linking to this <code>Image</code> class:</p>
  
  <pre><code>class Image(models.Model):
      thumb = ImageField(upload_to='images/uploads/')
      number = models.PositiveSmallIntegerField()
  </code></pre>
  
  <p>and a corresponding <code>ModelForm</code> like so:</p>
  
  <pre><code>class ListingEditForm(ModelForm):
      image1 = ImageField(required=False, label="Photo 1")
      image2 = ImageField(required=False, label="Photo 2")
      image3 = ImageField(required=False, label="Photo 3")
  
      class Meta:
          model = Listing
          exclude = ('images')
  </code></pre>
  
  <p>The idea is to not limit the number of images that can be associated with a <code>Listing</code> in the backend, but at this time I only need 3 images in the form. Uploading the images works fine, but how would you go about binding the form to a <code>Listing</code> instance so that the images are not 'None' when one views the edit form?</p>
  
  <p>Obviously, this alone won't work, because <code>image1</code>, <code>image2</code> and <code>image3</code> are only form fields, and not part of the model:</p>
  
  <pre><code>form = forms.ListingEditForm(instance=listing)
  </code></pre>
  
  <p>So adding a dictionary as the first parameter seems like the obvious thing to do:</p>
  
  <pre><code>form = forms.ListingEditForm({'image1': ...},instance=listing)
  </code></pre>
  
  <p>but what should the value of that <code>...</code> be? And how do I retrieve it from the <code>Listing</code> instance?</p>