title: Displaying static image in Django model
body: <p>If the user has a profile picture, I would like to display it. If he/she does not have a profile picture, I would like to display a default image in it's place.</p>
  
  <p>Is there a way to load a static image in a Django model property?</p>
  
  <p><em>Note: The user's profile picture loads with the following code. The <code>else</code> statement containing the default image does not work.</em></p>
  
  <p>This is what I have so far:</p>
  
  <p><strong><em>models.py:</em></strong></p>
  
  <pre><code>class UserProfile(models.Model):
      user = models.OneToOneField(settings.AUTH_USER_MODEL)
      profile_picture = models.ImageField(upload_to='user/profile_pictures/', 
                                      null=False, 
                                      blank=False)
  
      @property
      def default_profile_picture(self):
          if self.profile_picture:
              return "%s/%s" %(settings.MEDIA_URL, self.profile_picture)
          else:
              return settings.STATIC_URL + 'img/default_profile_picture.jpg'
  </code></pre>
  
  <p><strong><em>settings.py:</em></strong></p>
  
  <pre><code>STATIC_URL = '/static/'
  STATICFILES_DIRS = (
      os.path.join(os.path.dirname(BASE_DIR), "static", "static_dirs"),
  )
  STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static", "static_root")
  </code></pre>
  
  <p>Thank you in advance for all of your help!</p>