title: how to add an image in a django blog post
body: <p>I'm working on a blog with django and one of the last things I'm trying to figure out is how to post an image on my blog. I can already post some text very nicely through my admin panel and what I want now is the ability to add an image to the post. I'm a complete newbie so excuse any basic mistakes. </p>
  
  <p>I thought of a model like this:</p>
  
  <pre><code>class Post(models.Model):
      title = models.CharField(max_length=255)
      slug = models.SlugField(unique=True, max_length=255)
      description = models.CharField(max_length=255)
      content = models.TextField()
      published = models.BooleanField(default=True)
      created = models.DateTimeField(auto_now_add=True)
      image = models.ImageField(upload_to='media')
  
      class Meta:
          ordering = ['-created']
  
      def __str__(self):
          return ('%s') % self.title
  
      def get_absolute_url(self):
          return reverse('blog.views.post', args=[self.slug])
  </code></pre>
  
  <p>Although when I try this I get an error 'no such column blog_post.image', even after doing manage.py sqlflush and re-syncing my db.</p>
  
  <p>and I have this view:</p>
  
  <pre><code>def index(request):
      posts = Post.objects.filter(published=True)
      return render(request, 'blog/index.html', {'posts': posts})
  </code></pre>
  
  <p>Basically I would like the option of adding an image to a post and the template to display it.  </p>
  
  <p>I have tried admin-files and various other apps and tried so many snippets of code from other people's website but just nothing works so it's not for lack of trying. The closest to what I want is found here: <a href="http://drumcoder.co.uk/blog/2010/may/12/django-blog-images/" rel="nofollow">http://drumcoder.co.uk/blog/2010/may/12/django-blog-images/</a> (which also didn't work for me), just that I want it to be part of my Post model.</p>
  
  <p>Is there a simple way of doing this? How would the model and template have to look like? Any help would be greatly appreciated, thanks.    </p>