title: Nav Bar not working properly-Django
body: <p>I have created a base.html in my Django project from which I inherit rest of the html pages. In my base.html I have created a nav bar that displays Home,About,Contact and [Myprofile and Logout] if the user is logged in else it shows [Register]. 
  The problem is when I am logged in at my homepage I do see the button [Myprofile], but when I visit contact or About page, the [Myprofile] nav bar button is missing but [Logout] is working all fine.</p>
  
  <p>Here is my base.html</p>
  
  <pre><code>{% load staticfiles %}
  
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  
      &lt;title&gt;
      {% block title %}
       WEB PAGE BY SHASHANK
      {% endblock title %}
      &lt;/title&gt;
      &lt;link rel="stylesheet" href="{% static 'css/style.css' %}" /&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
          &lt;div id="page"&gt;
          &lt;div id="logo"&gt;
              &lt;h1&gt;&lt;a href="/" id="logoLink"&gt;S PORTAL&lt;/a&gt;&lt;/h1&gt;
          &lt;/div&gt;
          &lt;div id="nav"&gt;
              &lt;ul&gt;
                  &lt;li&gt;&lt;a href="{% url 'home' %}"&gt;Home&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="{% url 'about' %}"&gt;About&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="{% url 'contact' %}"&gt;Contact&lt;/a&gt;&lt;/li&gt;
  
          {% if user.is_authenticated %}
            &lt;li&gt;&lt;a href="{% url 'auth_logout' %}"&gt;Logout&lt;/a&gt;&lt;/li&gt;
               {% for thing in things %}
                  {% if user == thing.user %}
                    &lt;li&gt;&lt;a href="{% url 'thing_detail' slug=thing.slug %}"&gt;My Profile&lt;/a&gt;&lt;/li&gt;
                  {% endif %}
               {% endfor %}
  
  
          {% else %}
            &lt;li&gt;&lt;a href="{% url 'auth_login' %}"&gt;Login&lt;/a&gt;&lt;/li&gt;
  
          &lt;li&gt;&lt;a href="{% url 'registration_register' %}"&gt;Register&lt;/a&gt;&lt;/li&gt;
          {% endif %}
        &lt;/ul&gt;
          &lt;/div&gt;
  
  
          {% block content %}{% endblock content %}
  
  
          &lt;div id="footer"&gt;
              &lt;p&gt;
          Webpage made by &lt;a href="/" target="_blank"&gt;SHASHANK&lt;/a&gt;
              &lt;/p&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>About.html</p>
  
  <pre><code>{% extends 'layouts/base.html' %}
  {% block title %} ABOUT - {{ block.super }}{% endblock title %}
  
  
  
  {% block content %}
  
  &lt;h1&gt;WHAT WE DO&lt;/h1&gt;
  
  &lt;div id="content"&gt;
              &lt;h2&gt;ABOUT&lt;/h2&gt;
              &lt;p&gt;
                  We are a new software development company.
              &lt;/p&gt;
        &lt;p&gt;We are trying to change the world and expecting to getting paid for the same&lt;/p&gt;
              &lt;p&gt;
              Visit us on our &lt;a href="www.facebook.com"&gt; Facebook &lt;/a&gt; page.
              &lt;/p&gt;
          &lt;/div&gt;
  {% endblock content %}
  </code></pre>
  
  <p>Urls.py</p>
  
  <pre><code>from collection.backends import MyRegistrationView
  from django.conf.urls import include, url
  from django.contrib import admin
  from collection import views
  from django.views.generic import TemplateView
  from django.contrib.auth.views import (
      password_reset,
      password_reset_done,
      password_reset_confirm,
      password_reset_complete
      )
  
  urlpatterns = [
     url(r'^$', views.index, name='home'),
  
     url(r'^about/$',TemplateView.as_view(template_name='about.html'),name='about'),
  
     url(r'^contact/$',TemplateView.as_view(template_name='contact.html'),name='contact'),
  
     url(r'^things/(?P&lt;slug&gt;[-\w]+)/$','collection.views.thing_detail',name='thing_detail'),
  
     url(r'^things/(?P&lt;slug&gt;[-\w]+)/edit/$','collection.views.edit_thing',name='edit_thing'),
  
     url(r'^things/(?P&lt;slug&gt;[-\w]+)/edit/weight$','collection.views.edit_weight',name='edit_weight'),
  
     url(r'^things/(?P&lt;slug&gt;[-\w]+)/delete/weight$','collection.views.remove_weight',name='remove_weight'),
  
     #WORKING url(r'^things/(?P&lt;pk&gt;\d+)/remove/$', 'collection.views.remove_weight', name='remove_weight'),
  
     url(r'^things/$',TemplateView.as_view(template_name='weight_removed.html'),name='weight_removed'),
  
     url(r'^(?P&lt;slug&gt;[\w\d-]+)/(?P&lt;pk&gt;\d+)/$','collection.views.remove_weight',name='remove_weight'),
  
  
  
  
  
  
     #url(r'^edit/(?P&lt;slug&gt;\d+)/weights$', 'collection.views.AddWeight',name='AddWeight'),
     # the new password reset URLs
     url(r'^accounts/password/reset/$',password_reset,{'template_name':'registration/password_reset_form.html'},name="password_reset"),
     url(r'^accounts/password/reset/done/$',password_reset_done,{'template_name':'registration/password_reset_done.html'},name="password_reset_done"),
     url(r'^accounts/password/reset/(?P&lt;uidb64&gt;[0-9A-Za-z]+)-(?P&lt;token&gt;.+)/$',password_reset_confirm,{'template_name':'registration/password_reset_confirm.html'},name="password_reset_confirm"),
     url(r'^accounts/password/done/$',password_reset_complete,{'template_name':'registration/password_reset_complete.html'},name="password_reset_complete"),
  
  
     #setup additional registeration page
     url(r'^accounts/register/$',MyRegistrationView.as_view(),name='registration_register'),
     url(r'^accounts/create_thing/$','collection.views.create_thing',name='registration_create_thing'),
  
     url(r'^accounts/',include('registration.backends.default.urls')),
     url(r'^admin/', include(admin.site.urls)),
  
  
   ]
  </code></pre>
  
  <p>Views.py</p>
  
  <pre><code>from django.shortcuts import render,redirect,get_object_or_404
  from collection.models import Thing, Weight
  from collection.forms import ThingForm, WeightForm, ThingWeightFormSet
  from django.template.defaultfilters import slugify
  from django.contrib.auth.decorators import login_required
  from django.http import Http404
  from django.views.decorators.csrf import csrf_protect
  from django.views.generic import ListView, CreateView, UpdateView
  from django import forms
  
  def index(request):
      things = Thing.objects.all()
      return render(request,'index.html',{'things':things,})
  
  def thing_detail(request, slug):
      # grab the object...
      thingRA = Thing.objects.get(slug=slug)
      weights = thingRA.weights.all().order_by('-date')
      # and pass to the template
      return render(request, 'things/thing_detail.html', {'thing': thingRA, 'weights':weights,})
  
  def edit_thing(request, slug):
      # grab the object
      thing = Thing.objects.get(slug=slug)
      # set the form we're using
      form_class = ThingForm
  
      # if we're coming to this view from a submitted form
      if request.method == 'POST':
          # grab the data from the submitted form and apply to
          # the form
          form = form_class(data=request.POST, instance=thing)
          if form.is_valid():
              # save the new data
              form.save()
              return redirect('thing_detail', slug=thing.slug)
  # otherwise just create the form
      else:
          form = form_class(instance=thing)
  
  # and render the template
      return render(request, 'things/edit_thing.html', {'thing': thing,'form': form,})
  
  def create_thing(request):
      form_class = ThingForm
      if request.method == 'POST':
          form = form_class(request.POST)
          if form.is_valid():
              thing = form.save(commit=False)
              thing.user = request.user
              thing.slug = slugify(thing.name)
              thing.save()
              slug = slugify(thing.name)
              return redirect('thing_detail', slug=thing.slug)
      else:
          form = form_class()
  
      return render(request,'things/create_thing.html', {'form': form,})
  
  
  def edit_weight(request, slug):
      thing = get_object_or_404(Thing, slug=slug)
      if request.method == "POST":
          form = WeightForm(request.POST)
          if form.is_valid():
              weight = form.save(commit=False)
              weight.thingRA = thing
              weight.save()
              return redirect('thing_detail', slug=thing.slug)
      else:
          form = WeightForm()
      return render(request, 'things/edit_weight.html', {'form': form})
  
  """WORKING WEIGHT
  def remove_weight(request, pk):
              weight = get_object_or_404(Weight, pk=pk)
              thing_pk = weight.thingRA.pk
              weight.delete()
              return redirect('weight_removed')
  """
  
  
  def remove_weight(request, pk, slug):
              weight = get_object_or_404(Weight, pk=pk)
              thing = get_object_or_404(Thing, slug=slug)
              thing_pk = weight.thingRA.pk
              weight.delete()
              return redirect('thing_detail', slug=slug)
  
  
  @login_required
  def edit_thing(request, slug):
      # grab the object...
      thing = Thing.objects.get(slug=slug)
      # make sure the logged in user is the owner of the thing
      if thing.user != request.user:
          raise Http404
          # set the form we're using...
      form_class = ThingForm
      # if we're coming to this view from a submitted form,
      if request.method == 'POST':
           # grab the data from the submitted form and
           # apply to the form
           form = form_class(data=request.POST, instance=thing)
           if form.is_valid():
               # save the new data
               form.save()
               return redirect('thing_detail', slug=thing.slug)
      # otherwise just create the form
      else:
          form = form_class(instance=thing)
          # and render the template
      return render(request, 'things/edit_thing.html', {'thing': thing,'form': form,})
  </code></pre>