title: Display image from ImageField by means of form
body: <p><strong>prelude</strong>:</p>
  
  <p><a href="https://stackoverflow.com/a/17846328/3872976">Here</a>'s the simpliest way to display an ImageField. Lets assume I have 10 fields in my form and I don't wanna iterate over all of them in <code>template.html</code> just to check if it's an imageField and display it in a different way. I want to handle it via form or widget or something like <a href="https://stackoverflow.com/a/2444076/3872976">this</a>. So I want the leave template.html as it's bellow.</p>
  
  <p><strong>template.html</strong></p>
  
  
  
  <pre class="lang-html prettyprint-override"><code>&lt;table&gt;
      {{ form.as_table }}
  &lt;/table&gt;
  </code></pre>
  
  <p>And add to <strong>models.py</strong> an <code>image_tag</code> method:</p>
  
  
  
  <pre class="lang-python prettyprint-override"><code>class UserProfile(Model):
    photo = ImageField(upload_to=PHOTO_DIRECTORY)
    contacts = TextField(null=True)
    ... others
  
    def image_tag(self):
      return u'&lt;img src="%s" /&gt;' % self.photo.url
  
    image_tag.short_description = 'Image'
    image_tag.allow_tags = True
  </code></pre>
  
  <p><strong>forms.py</strong>:</p>
  
  <pre class="lang-python prettyprint-override"><code>class UserProfileForm(forms.ModelForm):
  
    class Meta:
      model = UserProfile
      fields = ('contacts', 'photo', 'image_tag', ...others)
  </code></pre>
  
  <p>I get an error that <code>Unknown field(s) (image_tag) specified for UserProfile</code> which is fair enought.</p>
  
  <p>I also tried to place it in <code>readonly_fields</code> but they don't display somehow. Do I have to create <a href="https://stackoverflow.com/a/27993901/3872976">list_view</a>? If yes where should it be?</p>
  
  <p>What do I miss here? Why the <code>image_tag</code> method should be a part of model instead of form? Model describes how data should persists in the database, not how it should present to user via form. This should be a part of form, shouldn't it?. Correct me please if I'm wrong. How do I solve the issue? Any help would be greatly appreciated!</p>