I have a project that spans multiple apps:
./project/app1
./project/app2
./project/...
Each app has a router for Django REST Framework to i
I ended up creating a single URLs file that contains all the routes I want at urls_api_v1.py:
router = DefaultRouter()
router.register(r'app1/foos', FooViewSet, base_name='foo')
router.register(r'app2/bars', BarViewSet, base_name='bar')
router.register(r'app2/bazs', BazViewSet, base_name='baz')
As a side effect, this allowed me to get rid of all the individual urls.py files in each app, which you would normally want but in this case the entire collection of apps needs a unified URL structure and so removal is more sensible.
I then reference it from urls.py
:
import api_v1
urlpatterns = patterns('',
...,
url(r'^api/v1/', include(api_v1, namespace='api-v1')),
)
Now if I ever want to change routes for v2, I can just include a v2 URLs file as well and eventually deprecate the v1 file.