title: Django - How to make a variable available to all templates?
body: <p>I would like to know how to pass a variable to all my templates, without repeating the same code on every method in my views.py file? </p>
  
  <p>In the example below I would like to make categories (an array of category objects) available to all templates in the web app.</p>
  
  <pre><code>Eg: I would like to avoid writing 'categories':categories on every method. Is it possible?
  </code></pre>
  
  <p><strong>One view method</strong></p>
  
  <pre><code>def front_page(request):
      categories = Category.objects.all()
      if is_logged_in(request) is False:
          return render_to_response('users/signup.html', {'is_logged_in': is_logged_in(request), 'categories':categories}, context_instance=RequestContext(request))
      else:
          return render_to_response('users/front_page.html', {'is_logged_in': is_logged_in(request), 'categories':categories},context_instance=RequestContext(request))
  </code></pre>
  
  <p><strong>Another view method</strong></p>
  
  <pre><code>def another_view_method(request):
      categories = Category.objects.all()
      return render_to_response('eg/front_page.html', {'is_logged_in': is_logged_in(request), 'categories':categories},context_instance=RequestContext(request))
  </code></pre>