title: Django- passing object in context for view works, but how to pass to include?
body: <p>UPDATED THANKS TO FEEDBACK: I'm including a template where I have access to the logged in user, but I'd like to be able to access that user's corresponding Person record (linked by a Profile model I made for supplemental fields), so I can show a little link to their page in the top nav. I can get that Person record for individual views in views.py, but my top_nav.html (template, or 'partial' in the laravel/rails worlds) gets included without using views.py so I'm not sure how to get/pass extra items to the template without views.py (and don't want to repeat passing the person to EVERY view that includes the top nav). I'd love to be able to add a method on Users, so I could access it like user.get_person, but extending auth.User looks like a nightmare. </p>
  
  <hr>
  
  <p>I'm making my first Django app I can pass/access a variable for the request user in one view but not another (partial/template) view. </p>
  
  <p>The details: I have a partial for my top navbar, where I want to include a link to the 'person page' for the logged in user. I even pass along the user when I include that partial view, though I'm not sure how to access it in views.py. In views.py, I can pass along a QuerySet for the user for the person_index view using request.user, but that's not available in  top_nav. I'm not sure if/how I can somehow grab the user in views.py from it being included when I call that top_nav from base.html? </p>
  
  <p>The person index view is set up like this: </p>
  
  <ul>
  <li>person_index.html extends base.html</li>
  <li>base.html includes the top_nav.html</li>
  <li>then the 'meat' of the view is in {% block content %}</li>
  </ul>
  
  <p>See views.py below: I grab the person for person_index (the face_link partial works), but obviously I don't want to get/pass it for EVERY view, instead I want to do it once and be able to pass it along to top_nav.html.</p>
  
  <p>views.py: </p>
  
  <pre><code>def person_index(request):
      accessible_branches = get_valid_branches(request)
      this_person = get_user_person(request.user).first()
      person_list = Person.objects.order_by('display_name') 
      context = { 'person_list': person_list,
                  'accessible_branches':accessible_branches, 'this_person': this_person}
      return render(request, 'familytree/person_index.html', context)
  
  def get_user_person(user):
      try:
          this_user_person = Person.objects.filter(profile__user_id=user)
      except Profile.DoesNotExist:
          this_user_person = None
      return this_user_person
  </code></pre>
  
  <p>top_nav.html: (I'd like to be able to get/pass the person record)</p>
  
  <pre><code>&lt;div class="container"&gt;
      &lt;div id="navbar" class="collapse navbar-collapse"&gt;
      &lt;ul class="nav navbar-nav"&gt;
  
          &lt;a href="{% url 'dashboard' %}"&gt;Home&lt;/a&gt;
          &lt;a href="{% url 'family_index' %}"&gt;Families&lt;/a&gt;
          &lt;a href="{% url 'person_index' %}"&gt;People&lt;/a&gt;
          {%  if this_person %}
              {% include "familytree/face_link.html" with person=this_person %}
          {% endif %}
      &lt;/ul&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>base.html: (the user record is available 'for free', need to get its corresponding profile__person)</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
      &lt;head&gt;
          &lt;meta charset="UTF-8"&gt;
          &lt;title&gt;
          Our big family tree
             {% block title %}
             {{ page_title|default:"Untitled Page" }}
            {% endblock title %}
          &lt;/title&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
      {% load static %}
      &lt;link rel="stylesheet" type="text/css" href="{% static 'familytree/style.css' %}"&gt;
  
  {#    Top nav#}
      {% include "familytree/top_nav.html" with user=user %} &lt;br/&gt;
  
  {#  Separator line#}
      &lt;div class="container-fluid"&gt;
          &lt;div class="row"&gt;
              &lt;div class="col-md-10"&gt;
                  &lt;hr class = "line" /&gt;
           &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
  {#  Page content#}
      &lt;div class="container"&gt;
          {% block content %}
              &lt;p&gt;Placeholder text in base template- this gets replaced with page content.&lt;/p&gt;
          {% endblock content %}
      &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Is there something I'm missing about to properly pass/get the user for this partial include? Are there rules about who can load what?</p>