title: Django; Tips for making views thin
body: <p>I'm a beginner and I have been  working on project using Django.
  I am wondering if there's a good way to avoid repeating the same code.
  Also if there are similar logic in some functions, how can I decide if the logic is organized or not.</p>
  
  <p>for example, </p>
  
  <pre><code>def entry_list(request):
      entry_list = Entry.objects.all()
  
      #this part is repeated
      page = request.GET.get('page', 1)
  
  
      paginator = Paginator(entry_list, 10)
  
      try:
          entries = paginator.page(page)
      except PageNotAnInteger:
          entries = paginator.page(1)
      except EmptyPage:
          entries = paginator.page(paginator.num_pages)
  
      return render(request, 'blog/entry_list.html', {'entries': entries})
  </code></pre>
  
  <p>The logic to paginate is repeated in some other functions as well.</p>
  
  <p>Where should I put the repeated code and how can I decide if I should organize code?</p>