title: Django-Rest-Framework dynamic url (dynamic prefix)
body: <p>i have historic data that i want to publish via webservice by versions. To do that i'm using Django-Rest-Framework. I'm already using this framework to provide other services but now it seems to be a little bit harder to accomplished this goal.</p>
  
  <p>The main goal is to provide a url:</p>
  
  <pre><code>http://127.0.0.1:8000/service/vocab (realtime) - done
  http://127.0.0.1:8000/service/v1/vocab (version 1)
  http://127.0.0.1:8000/service/v2/vocab (version 2)
  http://127.0.0.1:8000/service/vn/vocab (version n)
  </code></pre>
  
  <p>for this i'm trying to config the DRF router to make this possible.</p>
  
  <p>So the idea is something like this:</p>
  
  <p><strong>urls.py</strong></p>
  
  <pre><code>router = routers.DefaultRouter()
  router.register(r'vocab', views.VocabViewSet, 'vocabs')
  router.register(r'{version}/vocab', views.VersionViewSet, 'vocab')
  
      urlpatterns = patterns('',
      ...
          url(r'^service/', include(router.urls))
  
  
  )
  </code></pre>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>class VersionViewSet(viewsets.ModelViewSet):
          queryset = Version.objects.all()
          serializer_class = VersionSerializer
  
          @detail_route(methods=['post'], url_path='vocab')
              def get_vocabs(self, request, version='v1'):
              queryset = Version.objects.filter(version=version)
  </code></pre>
  
  <p>In this case it occurs :</p>
  
  <pre><code>invalid literal for int() with base 10: 'version'
  </code></pre>
  
  <p>That's because that DRF expects an int after <code>service/</code>.</p>
  
  <p>I'm trying to find a solution to this case. Can you provide any hint how can i make this ?</p>
  
  <p>Maybe <a href="http://www.django-rest-framework.org/api-guide/routers/#customizing-dynamic-routes" rel="nofollow">Customize dynamic routes</a> is the a good approach, what do you think ? If so, can you provide an example how to apply it in this case or similar?</p>
  
  <p>Thanks in advance.</p>