title: Multiple Integer Arguments in Django Rest Framework Router URL
body: <p>I'm setting up a url using Django Rest Framework viewsets and routers, and I'm trying to get the url to accept two values: first, to filter objects by a <code>user id</code>, and then by the object's id. (In my case, the objects are from a model called Request.) For example, <code>mysite.com/api/requestsbyuser/1/</code> would return all <code>Request</code> objects for <code>user 1</code>, and <code>mysite.com/api/requestsbyuser/1/23/</code> would return <code>Request</code> object with <code>pk=23</code> for <code>user 1</code>.</p>
  
  <p>Right now I have:</p>
  
  <pre><code># urls.py
  
  from django.conf.urls import url, include
  from rest_framework import routers
  from . import views
  
  router = routers.DefaultRouter()
  router.register(prefix=r'requestsbyuser/(?P&lt;user_id&gt;.+)', viewset=views.RequestsByUser, base_name='request')
  
  urlpatterns = [
      url(r'^', include(router.urls)),
  ]
  
  # views.py
  
  class RequestsByUser(viewsets.ModelViewSet):
      serializer_class = RequestsSerializer
  
      def get_queryset(self):
          u_id = self.kwargs['user_id']
          return Request.objects.filter(user_id=u_id)
  </code></pre>
  
  <p>This works well for listing all <code>Request</code> objects when the url is passed in only the <code>user_id</code>. But when I try to go to <code>mysite.com/api/requestsbyuser/1/23/</code>, I get the error:
  <code>invalid literal for int() with base 10: '1/23'</code>.</p>
  
  <p>Django debugging says that the following four url patterns are in my URLConf:</p>
  
  <pre><code>^api/ ^ ^requestsbyuser/(?P&lt;user_id&gt;.+)/$ [name='request-list']
  ^api/ ^ ^requestsbyuser/(?P&lt;user_id&gt;.+)\.(?P&lt;format&gt;[a-z0-9]+)/?$ [name='request-list']
  ^api/ ^ ^requestsbyuser/(?P&lt;user_id&gt;.+)/(?P&lt;pk&gt;[^/.]+)/$ [name='request-detail']
  ^api/ ^ ^requestsbyuser/(?P&lt;user_id&gt;.+)/(?P&lt;pk&gt;[^/.]+)\.(?P&lt;format&gt;[a-z0-9]+)/?$ [name='request-detail']
  </code></pre>
  
  <p>Am I missing something? I thought the DRF router would handle url paths with individual object primary key values, but it seems like it's treating the url after the prefix as an integer and ignoring the <code>/</code>.</p>