title: Django: coercing to Unicode NoneType found
body: <p>I am using <a href="http://code.google.com/p/django-stdimage2/" rel="nofollow">django-stdimage2</a> to rename and resize images in my project. It comes with the ability to delete images through the Django Admin interface: simply tick a check box and click Save.</p>
  
  <p>I can successfully add an image using the Django Admin but when I try to delete an image this error is returned:</p>
  
  <p><strong>Error Message</strong></p>
  
  <p>TypeError at /admin/app/gear_images/1/<br>
  coercing to Unicode: need string or buffer, NoneType found</p>
  
  <p><strong>Model</strong></p>
  
  <pre><code>class gear_images(models.Model):
      def __unicode__(self):
          return self.image.name
  
      gear_id = models.ForeignKey(gear)
      image = StdImageField(upload_to='images/gear', blank=True, size=(640, 480, True), thumbnail_size=(100, 100, True))
      description = models.CharField(max_length=100)
  </code></pre>
  
  <p><strong>Possible Cause</strong></p>
  
  <p>I assume an error is returned because the image has already been deleted from the database, so there is nothing to return.</p>
  
  <p><strong>Fix?</strong></p>
  
  <p>What is the correct way to code for this situation?</p>
  
  <p>Edit: Solution Found. Thank you, Vanessa!</p>
  
  <pre><code>def __unicode__(self):
      if self.image is None:
          return "None"
      elif self.image.name is None:
          return "None"
      else:
          return self.image.name
  </code></pre>
  
  <p>Thank you :-)</p>