title: The best approach to adding images in an article in Django
body: <p>It's a quite typical task to add several images with captions in arbitrary position within an article; what's the best way to do so in Django?</p>
  
  <p>Let's assume I have two models:</p>
  
  <pre><code>class Article(models.Model):
      heading = models.CharField(max_length=350)
      text = models.TextField()
  
  class ImageModel(models.Model):
      image = models.ImageField( upload_to = 'static/images/', max_length=300)
      img_alt = models.CharField(max_length=550, blank = True)
  </code></pre>
  
  <p>Now, I'd like to add a couple of images with captions in an article. Its text is stored with HTML formatting:</p>
  
  <pre><code>&lt;p&gt;Paragraph 1&lt;/p&gt;
  
  [Image 1 + caption]
  
  &lt;p&gt;Paragraph 2&lt;/p&gt;
  
  [Image 2 + caption]
  
  &lt;p&gt;Paragraph 3.&lt;/p&gt;
  
  &lt;...&gt;
  </code></pre>
  
  <p>What should I do to accomplish this? I guess it's necessary to create a custom tag, and make a tool for inserting this tag in a TextField with help of JS. While inserting, the id of a selected instance of ImageModel has to be passed somehow into the tag. And finally, this custom tag should be processed when rendering a template. Am I right? Is there any easier and more straightforward approach?</p>
  
  <p>(I use Django 2.0.)</p>