27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
from django.conf.urls import url, include
|
|
from rest_framework_nested.routers import SimpleRouter, NestedSimpleRouter
|
|
from api.event.views import EventViewSet, PlaceViewSet, ActivityTagViewSet,\
|
|
ActivityTemplateViewSet
|
|
|
|
# Create a router and register our viewsets with it.
|
|
router = SimpleRouter()
|
|
router.register(r'event', EventViewSet, 'event')
|
|
router.register(r'place', PlaceViewSet)
|
|
router.register(r'tag', ActivityTagViewSet)
|
|
|
|
# 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')
|
|
event_router.register(r'tag', ActivityTagViewSet, base_name='event-names')
|
|
event_router.register(r'activitytemplate', ActivityTemplateViewSet,
|
|
base_name='event-names')
|
|
|
|
|
|
# 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)),
|
|
url(r'^', include(event_router.urls)),
|
|
url(r'^api-auth/', include('rest_framework.urls',
|
|
namespace='rest_framework'))
|
|
]
|