title: django rest framework: Get url path variable in a view
body: <p>I have to pass the <code>product_id</code> (which is a string) into a view. There I have to do some DB operations based on the product id. How can I get that product id in that view? Actually what should be the parameter in the class <code>ProductDetailConfiguration</code> view? Now I am passing <code>viewsets.ModelViewSet</code>. Actually, this API call is not completely related to any model.</p>
  <p><strong># urls.py</strong></p>
  <pre><code>  url(r'^product-configuration/(?P&lt;product_id&gt;[\w-]+)/$', views.ProductDetailConfiguration, name='product-configuration'),
  </code></pre>
  <p><strong># views.py</strong></p>
  <pre><code>class ProductDetailConfiguration(viewsets.ModelViewSet):
  
      queryset = Product.objects.all()
  
      def get_queryset(self, **kwargs):
        
          queryset = Product.objects.all()
          product_id = self.request.get('product_id', None)
          #filter query set based on the product_id
          return queryset
  
      serializer_class = ProductConfigurationSerializer
  </code></pre>