poulpe/api/urls.py

27 lines
1.1 KiB
Python
Raw Normal View History

2017-07-18 17:48:59 +02:00
from django.conf.urls import url, include
2017-07-21 17:03:33 +02:00
from rest_framework_nested.routers import SimpleRouter, NestedSimpleRouter
2017-07-20 15:08:19 +02:00
from api.event.views import EventViewSet, PlaceViewSet, ActivityTagViewSet,\
ActivityTemplateViewSet
2017-07-18 17:48:59 +02:00
# Create a router and register our viewsets with it.
2017-07-21 17:03:33 +02:00
router = SimpleRouter()
2017-07-18 17:48:59 +02:00
router.register(r'event', EventViewSet)
2017-07-20 15:08:19 +02:00
router.register(r'place', PlaceViewSet)
router.register(r'tag', ActivityTagViewSet)
router.register(r'activitytemplate', ActivityTemplateViewSet)
2017-07-18 17:48:59 +02:00
2017-07-21 17:03:33 +02:00
# Register nested router and register someviewsets vith it
event_router = NestedSimpleRouter(router, r'event', lookup='event')
event_router.register(r'place', PlaceViewSet, base_name='event-names')
2017-07-22 02:09:31 +02:00
event_router.register(r'tag', ActivityTagViewSet, base_name='event-names')
2017-07-21 17:03:33 +02:00
2017-07-18 17:48:59 +02:00
# The API URLs are now determined automatically by the router.
# Additionally, we include the login URLs for the browsable API.
urlpatterns = [
url(r'^', include(router.urls)),
2017-07-21 17:03:33 +02:00
url(r'^', include(event_router.urls)),
2017-07-18 17:48:59 +02:00
url(r'^api-auth/', include('rest_framework.urls',
namespace='rest_framework'))
]