title: Getting the pk from url in Django
body: <p>here is my URL structure that I use to get the item pk in the link :</p>
  
  <p><strong>urls.py</strong></p>
  
  <pre><code>path('categories/&lt;int:item_category&gt;/', views.item_category, name="item_category"),
  </code></pre>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>def item_category(request, pk):
      item_category = get_object_or_404(Categories, pk=pk)
      ids = [self.kwargs.get('pk')]
      cat_id = Categories.objects.get(pk=ids)
  
      return render(request, 'items_modal.html', {'item_category': item_category,
                                                  'cat_id': cat_id
                                                  })
  </code></pre>
  
  <p>Now I want to use the pk to get the result on the new link 
  here is my <strong>HTML</strong></p>
  
  <pre><code>  &lt;div class="modal-dialog" role="document"&gt;
      &lt;div class="modal-content"&gt;
        &lt;div class="modal-header"&gt;
          &lt;h5 class="modal-title" id="exampleModalLabel"&gt;{{ cat_id }}&lt;/h5&gt;
  </code></pre>