title: Django display each categories url on base.html
body: <p>I am a beginner in Django and create video streaming apps, the functions are basically to add videos and display those on different pages by categories. I am struggling to obtain URL for each category to display limited videos on each page. I could display categories and the link in one page by using for loop. However, I want to have those URLs on the Nav bar on base.html.<br />
  videos/models.py</p>
  <pre><code>from tabnanny import verbose
  from unicodedata import category
  import uuid
  from django.contrib.auth import get_user_model
  from django.db import models
  from django.conf import settings
  
  class VideoCategory(models.Model):
      name = models.CharField(choices=settings.CATEGORIES, max_length=45)
  
      def __str__(self):
          return self.name
      class Meta:
          verbose_name = 'カテゴリー'
          verbose_name_plural = 'カテゴリー'
  
  
  # Create your models here.
  class VideoContent(models.Model):
      id = models.UUIDField(
          primary_key=True,
          default=uuid.uuid4,
          editable=False, 
          unique=True,
      )
      title = models.CharField('タイトル', max_length=50)
      comment = models.CharField('内容',max_length=500)
      url = models.URLField('URL', max_length=200)
      published_date = models.DateTimeField('投稿日', auto_now_add=True)
      category = models.ForeignKey(
          VideoCategory, verbose_name = 'カテゴリー', 
          on_delete=models.PROTECT, null=True, blank=True
      )
  
      def __str__(self):
          return self.title
  
      class Meta:
          verbose_name = '動画投稿'
          verbose_name_plural = '動画投稿'
  </code></pre>
  <p>video/views.py</p>
  <pre><code>from django.contrib.auth.mixins import LoginRequiredMixin
  
  
  from unicodedata import category
  from django.shortcuts import render, get_object_or_404
  from .models import VideoCategory, VideoContent
  from django.urls import reverse_lazy, reverse
  from django.shortcuts import render
  from django.views.generic import (
   ListView, 
   CreateView,
   UpdateView,
   DeleteView,
  )
  from .forms import VideoPostForm
  
  class VideoCreateView(LoginRequiredMixin ,CreateView):
      template_name = 'video/videoAdd.html'
      success_url= '/video/'
      model = VideoContent
      form_class = VideoPostForm
      login_url = 'login'
  
  
  class VideoListView(LoginRequiredMixin, ListView):
      model = VideoContent
      template_name = &quot;video/videoView.html&quot;
      context_object_name = 'video'
      login_url = 'login'
      
      def get_queryset(self):
          queryset =VideoContent.objects.filter(category_id=1)
          return queryset
  
  
  
  class CategoryView(LoginRequiredMixin, ListView):
      model = VideoContent
      template_name = 'video/videoView.html'
      login_url = 'login'
  
      def get_queryset(self):
          category = VideoCategory.objects.get(name=self.kwargs['category'])
          queryset = VideoContent.objects.filter(category=category)
          return queryset
  
      def  get_context_data(self, **kwargs):
          context = super().get_context_data(**kwargs)
          context[&quot;category_key&quot;] = self.kwargs['category'] 
          return context
      
  class VideoDeleteView(LoginRequiredMixin, DeleteView):
      model = VideoContent
      template_name = 'video/video_delete_confirmation.html'
      success_url = reverse_lazy('video:videoView')
      login_url = 'login'
     
  class VideoUpdate(LoginRequiredMixin, UpdateView):
      template_name = 'video/video_update_form.html'
      model = VideoContent
      fields = ['title', 'comment', 'url', 'category']
      success_url = reverse_lazy('video:videoView')
      login_url = 'login'
  </code></pre>
  <p>video/urls.py</p>
  <pre><code>from django.urls import path
  from .views import VideoListView, VideoDeleteView,VideoUpdate, VideoCreateView
  
  app_name='video'
  
  urlpatterns = [
          path('',  VideoCreateView.as_view(), name='videoAdd'),
          path('videoView',  VideoListView.as_view(), name='videoView'),
          path('&lt;slug:pk&gt;/delete/', VideoDeleteView.as_view(), name='delete'),
          path('&lt;slug:pk&gt;/update/', VideoUpdate.as_view(), name='update'),
  
  ]
  </code></pre>
  <p>templates/_base.html</p>
  <pre><code>            &lt;!-- Nav Item - Utilities Collapse Menu --&gt;
              &lt;li class=&quot;nav-item&quot;&gt;
                  &lt;a class=&quot;nav-link collapsed&quot; href=&quot;#&quot; data-toggle=&quot;collapse&quot; data-target=&quot;#collapseFx&quot;
                      aria-expanded=&quot;true&quot; aria-controls=&quot;collapseUtilities&quot;&gt;
                      &lt;i class=&quot;fas fa-fw fa-wrench&quot;&gt;&lt;/i&gt;
                      &lt;span&gt;外為市場&lt;/span&gt;
                  &lt;/a&gt;
                  &lt;div id=&quot;collapseFx&quot; class=&quot;collapse&quot; aria-labelledby=&quot;headingTwo&quot;
                      data-parent=&quot;#accordionSidebar&quot;&gt;
                      &lt;div class=&quot;bg-white py-2 collapse-inner rounded&quot;&gt;
  
                          &lt;a class=&quot;collapse-item&quot; href=&quot;{% url 'video:videoView' category_id=1 %}&quot; id =&quot;diplayKey&quot;&gt;Business-Basic&lt;/a&gt;
                          &lt;a class=&quot;collapse-item&quot; href=&quot;{% url 'video:videoView'  %}&quot;&gt;Business-Advance&lt;/a&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/li&gt;
  </code></pre>