title: How to get primary key from template in django?
body: <p>Here I am trying to get user_to_toggle id but that is coming none and i guess this is because i am doing something wrong. I am confuse that how can i get user_to_toggle id. I am getting his username but i want user id too. Here is my code.</p>
  <p>views,pyy</p>
  <pre><code>class UserProfileFollowToggle(LoginRequiredMixin,View):
      login_url = '/accounts/login/'
      def post(self, request, *args, **kwargs):
              user_pk_to_toggle=kwargs.get('pk') #this is returning None. 
              username_to_toggle = request.POST.get(&quot;username&quot;)#this is returning me username of toggle user. 
              profile_, is_following = UserProfile.objects.toggle_follow(request.user, request.user.id ,username_to_toggle)
              return redirect(f'/profiles/{username_to_toggle}')
  </code></pre>
  <p>follow_to_toggle.html</p>
  <pre><code>&lt;form class='form' method='POST' action=&quot;{% url 'profiles:toggle'%}&quot;&gt;
  {% csrf_token %}
  &lt;input type='hidden' name='username' value=&quot;{% if username %}{{ username }}{% else %}hello{% endif %}&quot;&gt;
  &lt;button class='btn {% if is_following %}btn-warning{% else %}btn-primary{% endif %}'&gt;{% if is_following %}Unfollow {% else %}Follow{% endif %}&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  <p>if more code is required than tell me i will update my question with that information.</p>
  <p>urls.py</p>
  <pre><code>app_name = 'profiles'
  
      urlpatterns = [
          path('user-profile/',UserProfileFollowToggle.as_view(),name = 'toggle'),
          path('&lt;str:username&gt;/',UserProfileDetailView.as_view(),name = 'detail'),
      
      ]
  </code></pre>