title: django- how to serve an image in all templates of django app?
body: <p>I want to show user's avatar in all pages of my django project.
  I use an <code>&lt;img&gt;</code> tag in base.html and in the href I write: <code>{{ request.user.profile.get_avatar }}</code>.
  but it does not work properly.
  in the first page of project it works but in another pages does not work.</p>
  
  <p>The problem is for addresses.
  for example in index page with url www.mysite.com/index the image shows. but in www.mysite.com/v1/v2/v3  image does not show.</p>
  
  <p>This is the get_avatar method of profile class:</p>
  
  <pre><code>def get_avatar(self):
      if self.avatar:
          return os.path.join(settings.MEDIA_URL + str(self.avatar))
      else:
          return os.path.join(settings.MEDIA_URL + str('avatars/student.jpg'))
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/i0L51.png" rel="nofollow noreferrer">view of not working picture</a></p>
  
  <pre><code>def profile_me(request):
      the_profile = get_object_or_404(Profile, user=request.user)
      klasses = KlassStudents.objects.filter(student=request.user.profile)
      return render(request, 'ejazeostad/profile/profile.html', {'profile': the_profile, 'klasses': klasses})
  </code></pre>