title: Is it possible to create own class in Django views to avoid code duplicates?
body: <p>I have 3 subpages to redirect to and each of them must contain the same piece of code:</p>
  
  <pre><code>new_user = User.objects.get(username=user)
      user_profile = Profile.objects.get(user=new_user)
      adverts = Advert.objects.filter(user=new_user)
      editable = False
      if request.user.username == user:
          editable = True
      context = {
          "objects":adverts,
          "user_profile":user_profile,
          "no_data":"No comments",
          "editable":editable,
          "user":user
      }
  </code></pre>
  
  <p>and only "objects" in context change. 3 almost the same methods don;t look good. Is there a way to inherit that code from one class or maybe create own tag to do it ? I'm kinda new in django and I do not know what are the good habits here ;)</p>