Ejemplo n.º 1
0
    def register_with(self, router):
        """
        Register this tree with the specified router and create new routers as necessary.

        Args:
            router (routers.DefaultRouter): router to register the viewset with.
            created_routers (list): A running list of all routers.
        Returns:
            list: List of new routers, including those created recursively.
        """
        created_routers = []
        # Root node does not need to be registered, and it doesn't need a router either.
        if self.viewset:
            router.register(self.viewset.urlpattern(), self.viewset,
                            self.viewset.view_name())
            if self.children:
                router = routers.NestedDefaultRouter(
                    router,
                    self.viewset.urlpattern(),
                    lookup=self.viewset.router_lookup)
                created_routers.append(router)
        # If we created a new router for the parent, recursively register the children with it
        for child in self.children:
            created_routers = created_routers + child.register_with(router)
        return created_routers
Ejemplo n.º 2
0
def get_nested_posts_router(parent_router, parent_name=''):
    """
    Given a parent router and its routing key, this will return a nested
    router that will allow posts to be nested under the parent descriptive URLs
    """
    posts_router = routers.NestedDefaultRouter(parent_router,
                                               parent_name,
                                               lookup='user')
    posts_router.register('posts', views.PostViewSet, base_name='user-posts')
    return posts_router
Ejemplo n.º 3
0
def get_nested_comments_router(parent_router, parent_name='', lookup='post'):
    """
    Given a parent router and its routing key, this will return a nested
    router that will allow comments to be nested under the parent descriptive URLs
    """
    comments_router = routers.NestedDefaultRouter(parent_router,
                                                  parent_prefix=parent_name,
                                                  lookup=lookup)
    comments_router.register('comments',
                             views.CommentViewSet,
                             base_name=f'{lookup}-comments')
    return comments_router
Ejemplo n.º 4
0
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from rest_framework_nested import routers

from dfys.core import views

router = routers.DefaultRouter()
router.register(r'categories', views.CategoryViewSet, basename='category')
router.register(r'skills', views.SkillViewSet, basename='skill')
router.register(r'activities', views.ActivitiesViewSet, basename='activity')

activities_router = routers.NestedDefaultRouter(router,
                                                r'activities',
                                                lookup='activity')
activities_router.register(r'entries',
                           views.EntriesViewSet,
                           basename='activity-entry')

auth_routes = [
    path('api/auth/login', views.login_view),
    path('api/auth/logout', views.logout_view),
    path('api/auth/register', views.register),
]

urlpatterns = [
    path('', views.index, name='index'),
    path('admin/', admin.site.urls),
    path('api/', include(router.urls)),
Ejemplo n.º 5
0
router.register(r'asset-user-auth-infos', api.AssetUserAuthInfoViewSet,
                'asset-user-auth-info')
router.register(r'gathered-users', api.GatheredUserViewSet, 'gathered-user')
router.register(r'favorite-assets', api.FavoriteAssetViewSet, 'favorite-asset')
router.register(r'system-users-assets-relations',
                api.SystemUserAssetRelationViewSet,
                'system-users-assets-relation')
router.register(r'system-users-nodes-relations',
                api.SystemUserNodeRelationViewSet,
                'system-users-nodes-relation')
router.register(r'system-users-users-relations',
                api.SystemUserUserRelationViewSet,
                'system-users-users-relation')

cmd_filter_router = routers.NestedDefaultRouter(router,
                                                r'cmd-filters',
                                                lookup='filter')
cmd_filter_router.register(r'rules', api.CommandFilterRuleViewSet,
                           'cmd-filter-rule')

urlpatterns = [
    path('assets/<uuid:pk>/gateways/',
         api.AssetGatewayListApi.as_view(),
         name='asset-gateway-list'),
    path('assets/<uuid:pk>/platform/',
         api.AssetPlatformRetrieveApi.as_view(),
         name='asset-platform-detail'),
    path('assets/<uuid:pk>/tasks/',
         api.AssetTaskCreateApi.as_view(),
         name='asset-task-create'),
    path('asset-users/tasks/',
Ejemplo n.º 6
0
from django.conf.urls import include, url
from rest_framework import routers
from rest_framework_nested import routers as nested_routers

from . import views

router = routers.DefaultRouter()
router.register(r'restaurants',
                views.RestaurantsViewSet,
                basename='restaurants')
router.register(r'tickets', views.PurchaseTicketViewSet, basename='tickets')

nested_router = nested_routers.NestedDefaultRouter(router,
                                                   r'restaurants',
                                                   lookup='restaurant')
nested_router.register('tickets',
                       views.RestaurantTicketsModelViewSet,
                       basename='restaurant-tickets')

urlpatterns = [
    url(r'', include(router.urls)),
    url(r'', include(nested_router.urls)),
]
Ejemplo n.º 7
0
from django.urls import path, include
from . import views
from rest_framework_nested import routers

router = routers.DefaultRouter()
router.register('art', views.ProfessionViewSet)
router.register('', views.PersonViewSet)

names_router = routers.NestedDefaultRouter(router, '', lookup="name")
names_router.register('movies',
                      viewset=views.PersonMovieViewset,
                      basename="name-movie")
names_router.register('awards',
                      viewset=views.PersonAwardViewset,
                      basename="name-award")

urlpatterns = [
    path('', include(router.urls)),
    path('', include(names_router.urls)),
]
Ejemplo n.º 8
0
router = BulkRouter()
router.register(r'roles', api.RoleViewSet, 'role')
router.register(r'role-bindings', api.RoleBindingViewSet, 'role-binding')

router.register(r'system-roles', api.SystemRoleViewSet, 'system-role')
router.register(r'system-role-bindings', api.SystemRoleBindingViewSet,
                'system-role-binding')

router.register(r'org-roles', api.OrgRoleViewSet, 'org-role')
router.register(r'org-role-bindings', api.OrgRoleBindingViewSet,
                'org-role-binding')

router.register(r'permissions', api.PermissionViewSet, 'permission')

system_role_router = routers.NestedDefaultRouter(router,
                                                 r'system-roles',
                                                 lookup='system_role')
system_role_router.register(r'permissions', api.SystemRolePermissionsViewSet,
                            'system-role-permission')

org_role_router = routers.NestedDefaultRouter(router,
                                              r'org-roles',
                                              lookup='org_role')
org_role_router.register(r'permissions', api.OrgRolePermissionsViewSet,
                         'org-role-permission')

urlpatterns = []

urlpatterns += router.urls + system_role_router.urls + org_role_router.urls
Ejemplo n.º 9
0
from rest_framework_nested import routers
from apps.foods.viewsets import FoodViewSet, FoodCategoryViewSet
from apps.restaurants.viewsets import RestaurantViewSet

router = routers.DefaultRouter()

router.register('restaurants', RestaurantViewSet, base_name='restaurants')

restaurant_router = routers.NestedDefaultRouter(router,
                                                'restaurants',
                                                lookup='restaurant')
restaurant_router.register('categories',
                           FoodCategoryViewSet,
                           base_name='categories')

category_router = routers.NestedDefaultRouter(restaurant_router,
                                              'categories',
                                              lookup='category')
category_router.register('foods', FoodViewSet, base_name='foods')
Ejemplo n.º 10
0
from rest_framework_nested import routers

from .views import (SongViewSet,
                    SongCommentViewSet,

                    SongRequestManager,
                    SongRequestViewSet,
                    SongRequestCommentViewSet,

                    HistoryViewSst,
                    StatisticViewSet,)

song_router = routers.DefaultRouter()
song_router.register(r'songs', SongViewSet)
song_comment_router = routers.NestedDefaultRouter(song_router, r'songs', lookup='song')
song_comment_router.register(r'comments', SongCommentViewSet, basename='song-comments')


song_request_router = routers.DefaultRouter()
song_request_router.register(r'songs', SongRequestViewSet, basename='playlist-songs')
song_request_router.register(r'history', HistoryViewSst)
song_request_router.register(r'', SongRequestManager)

song_request_comment_router = routers.NestedDefaultRouter(song_request_router, r'songs', lookup='playlist_song')
song_request_comment_router.register(r'comments', SongRequestCommentViewSet, basename='playlist-song-comments')

statistic_router = routers.DefaultRouter()
statistic_router.register(r'', StatisticViewSet, basename='stats')

urlpatterns = [
Ejemplo n.º 11
0
from django.urls import path, include

from . import views
from rest_framework_nested import routers

router = routers.DefaultRouter()

router.register(r'locations', views.LocationView)
router.register(r'roles', views.RoleView)
router.register(r'acolytes', views.AcolyteView)
router.register(r'groups', views.GroupView)
router.register(r'types', views.TypeView, basename='types')
router.register(r'plans', views.PlanView, basename='plans')
router.register(r'current', views.CurrentPlanView, basename='current')

masses_router = routers.NestedDefaultRouter(router, r'plans', lookup='plan')
masses_router.register(r'masses', views.MassView, basename='masses')

mass_acolyte_router = routers.NestedDefaultRouter(masses_router,
                                                  r'masses',
                                                  lookup='mass')
mass_acolyte_router.register(r'acolytes',
                             views.MassAcolyteView,
                             basename='mass-acolytes')

requirements_router = routers.NestedDefaultRouter(router,
                                                  r'types',
                                                  lookup='type')
requirements_router.register(r'requirements',
                             views.RequirementView,
                             basename='requirements')
Ejemplo n.º 12
0
from XroadsAPI import views, admin_views

app_name = "api"

router = routers.SimpleRouter(trailing_slash=True)
# ----- Normal Routes
# user/
# router.register('user', views.UserViewset, basename="user")

# district/
router.register('district', views.DistrictViewset, basename="district")

# district/school/
school_router = routers.NestedDefaultRouter(router,
                                            "district",
                                            lookup=r"district")
school_router.register('school', views.SchoolViewset, basename="school")

# district/school/club/
club_router = routers.NestedDefaultRouter(school_router,
                                          'school',
                                          lookup=r"school")
club_router.register('club', views.ClubViewset, basename='club')

# ----- ADMIN ROUTES
# admin/user/
router.register(r'admin/user', admin_views.UserViewset, basename="admin-user")

# admin/district/
router.register('admin/district',
Ejemplo n.º 13
0
from polls.api.views.option import OptionViewSet
from polls.api.views.poll import PollViewSet
from rest_framework_nested import routers as nested_routers
from rest_framework import routers

polls_router = routers.DefaultRouter()
polls_router.register('polls', PollViewSet, basename='poll')

options_router = nested_routers.NestedDefaultRouter(polls_router,
                                                    'polls',
                                                    lookup='poll')
options_router.register('options', OptionViewSet, basename='poll-option')

urlpatterns = options_router.urls + polls_router.urls
Ejemplo n.º 14
0
from django.conf.urls import url, include
from rest_framework_nested import routers
from rest_framework.routers import SimpleRouter
from api.views import CityViewSet, SpotViewSet, StateViewSet, NearestSpotViewSet, PostViewSet, FirstUserViewSet, PossiblePartnerViewSet

router = SimpleRouter()
router.register(r'firstusers', FirstUserViewSet)
router.register(r'possiblepartners', PossiblePartnerViewSet)
router.register(r'states', StateViewSet, base_name="states")
router.register(r'posts', PostViewSet, base_name="posts")
router.register(r'nearest', NearestSpotViewSet, base_name="nearest")


state_router = routers.NestedDefaultRouter(router, r'states', lookup="state")
state_router.register(r'cities', CityViewSet, base_name="state-cities")

cities_router = routers.NestedSimpleRouter(state_router, r'cities', lookup="city")
cities_router.register(r'spots', SpotViewSet, base_name="cities-spots")

urlpatterns = [
    url(r'^', include(router.urls)),
    url(r'^', include(state_router.urls)),
    url(r'^', include(cities_router.urls))
]
Ejemplo n.º 15
0
#  specific language governing permissions and limitations
#  under the License.

from django.urls import path
from django.conf.urls import include
from rest_framework.schemas import get_schema_view
from rest_framework_nested import routers
from . import views

router = routers.DefaultRouter()
router.register('users', views.UserViewSet)
router.register('groups', views.GroupViewSet)
router.register('products', views.ProductViewSet)

products_router = routers.NestedDefaultRouter(router,
                                              'products',
                                              lookup='product')
products_router.register('tickets',
                         views.TicketViewSet,
                         basename='product-tickets')
products_router.register('components',
                         views.ComponentViewSet,
                         basename='product-components')
products_router.register('milestones',
                         views.MilestoneViewSet,
                         basename='product-milestones')
products_router.register('versions',
                         views.VersionViewSet,
                         basename='product-versions')

urlpatterns = [
Ejemplo n.º 16
0
from django.conf.urls import url
from django.urls import include
from rest_framework_nested import routers

from sunscraper.ecb import views as ecb_views

v1_router = routers.DefaultRouter()

v1_router.register(r'currencies', ecb_views.CurrencyViewSet)

currency_router = routers.NestedDefaultRouter(v1_router,
                                              r'currencies',
                                              lookup='currency')
currency_router.register(r'rates',
                         ecb_views.RateViewSet,
                         base_name='currency_rates')

urlpatterns = [
    url(r'^', include(v1_router.urls)),
    url(r'^', include(currency_router.urls)),
]

app_name = 'api'
Ejemplo n.º 17
0
from django.urls import path
from django.conf.urls import url, include

from rest_framework_nested import routers
from . import views

router = routers.DefaultRouter()
router.register(r'trips', views.TripViewset)

trips_router = routers.NestedDefaultRouter(router, r'trips', lookup='trips')
trips_router.register(r'places', views.PlaceViewset)

router.register(r'users', views.UserViewset)

urlpatterns = (
    url(r'^', include(router.urls)),
    url(r'^', include(trips_router.urls)),
)
Ejemplo n.º 18
0
"""
mappoints URL Configuration
"""
from django.conf.urls import include, url
from django.contrib import admin
from rest_framework_nested import routers
from rest_framework_jwt.views import obtain_jwt_token, refresh_jwt_token

from mappoints.core import views

router = routers.DefaultRouter()
router.register(r'users', views.UserViewSet, base_name='user')
router.register(r'points', views.PointViewSet, base_name='point')

users_router = routers.NestedDefaultRouter(router, r'users', lookup='user')
users_router.register(r'points', views.UserPointViewSet, base_name='user-point')
users_router.register(r'comments', views.UserCommentViewSet, base_name='user-comment')
users_router.register(r'stars', views.UserStarViewSet, base_name='user-star')

points_router = routers.NestedDefaultRouter(router, r'points', lookup='point')
points_router.register(r'comments', views.PointCommentViewSet, base_name='point-comment')
points_router.register(r'stars', views.PointStarViewSet, base_name='point-star')
points_router.register(r'tags', views.PointTagViewSet, base_name='point-tag')

urlpatterns = [
    url(r'^', include(router.urls)),
    url(r'^', include(users_router.urls)),
    url(r'^', include(points_router.urls)),
    url(r'^auth/', include('rest_framework.urls', namespace='rest_framework')),
    url(r'^admin/', admin.site.urls),
    url(r'^api-token-auth/', obtain_jwt_token),
Ejemplo n.º 19
0
from accounts.api.urls import user_router
from homeworks.api.views.homework_user import (HomeworkUserInlineViewSet,
                                               HomeworkUserViewSet)
from rest_framework_nested import routers as nested_routers
from rest_framework import routers

homeworks_router = routers.DefaultRouter()
homeworks_router.register('homeworks',
                          HomeworkUserViewSet,
                          basename='homework')

homeworks_inline_router = nested_routers.NestedDefaultRouter(user_router,
                                                             'users',
                                                             lookup='user')
homeworks_inline_router.register('homeworks',
                                 HomeworkUserInlineViewSet,
                                 basename='homework_inline')

urlpatterns = homeworks_inline_router.urls + homeworks_router.urls
Ejemplo n.º 20
0
from . import views

router = DefaultRouter()
router.register('categories', views.CategoryViewSet)

category_router = routers.NestedSimpleRouter(router,
                                             r'categories',
                                             lookup='category')
category_router.register(r'dishes', views.DishViewSet, base_name='dishes')

category_dish_router = routers.NestedSimpleRouter(category_router,
                                                  r'dishes',
                                                  lookup='dish')
category_dish_router.register(r'reviews',
                              views.DishReviewViewSet,
                              base_name='reviews')

router.register('dishes', views.DishViewSet)
dish_router = routers.NestedDefaultRouter(router, r'dishes', lookup='dish')
dish_router.register(r'reviews', views.DishReviewViewSet, base_name='reviews')

router.register('reviews', views.DishReviewViewSet)
router.register('images', views.DishImageViewSet)

urlpatterns = [
    path('', include(router.urls)),
    path('', include(category_router.urls)),
    path('', include(category_dish_router.urls)),
    path('', include(dish_router.urls)),
]
Ejemplo n.º 21
0
from rest_framework_nested import routers

from post.api.v1.views import PostViewSet
from topic.api.v1.urls import router

post_router = routers.NestedDefaultRouter(router, 'topics', lookup='topic')
post_router.register('posts', PostViewSet, basename='posts')

urlpatterns = post_router.urls
Ejemplo n.º 22
0
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf import settings
from django.conf.urls import url, include
from django.contrib import admin
from rest_framework_nested import routers

from mahjong_statboard import views


router = routers.DefaultRouter()
router.register(r'instances', views.InstancesViewSet)

instances_router = routers.NestedDefaultRouter(router, r'instances', lookup='instance')
instances_router.register(r'games', views.GamesViewSet, base_name='games')
instances_router.register(r'players', views.PlayersViewSet, base_name='players')
instances_router.register(r'ratings', views.RatingsViewSet, base_name='ratings')
instances_router.register(r'stats', views.StatsViewSet, base_name='stats')
instances_router.register(r'meetings', views.MeetingsViewSet, base_name='meetings')


urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^api/auth/', include('rest_auth.urls')),
    url(r'^api/', include(router.urls + instances_router.urls)),
    url(r'^api/instances/(?P<instance_pk>[0-9]+)/games_csv/', views.GamesListCsv.as_view(), name='games-csv'),
    url(r'^api/instances/(?P<instance_pk>[0-9]+)/player-merge/', views.PlayerMergeView.as_view(), name='players-merge'),
]
Ejemplo n.º 23
0
from django.conf.urls import url, include
from rest_framework_nested import routers

from api.projects.views import ProjectViewSet
from api.skills.views import SkillViewSet
from api.tags.views import TagViewSet
from api.hearts.views import HeartViewSet

router = routers.DefaultRouter()
router.register(r'projects', ProjectViewSet, 'project')
router.register(r'tags', TagViewSet, 'tag')
router.register(r'skills', SkillViewSet, 'skill')
router.register(r'hearts', HeartViewSet, 'heart')

projects_router = routers.NestedDefaultRouter(router,
                                              r'projects',
                                              lookup='project')

projects_router.register(r'hearts', HeartViewSet, base_name='project-hearts')

urlpatterns = [
    url(r'^api/', include(router.urls)),
    url(r'^api/', include(projects_router.urls)),
    url(r'^api/api-auth/',
        include('rest_framework.urls', namespace='rest_framework'))
]
Ejemplo n.º 24
0
from rest_framework_nested import routers
from apps.users.viewsets import SellerViewSet, CustomerViewSet
from apps.products.viewsets import ProductCategoryViewSet, ProductViewSet
from apps.carts.viewsets import CartViewSet
from apps.orders.viewsets import OrderViewSet

router = routers.DefaultRouter()

router.register("customers", CustomerViewSet)
router.register("sellers", SellerViewSet)
router.register("categories", ProductCategoryViewSet, base_name="categories")
router.register("cart", CartViewSet)

user_router = routers.NestedDefaultRouter(router, "customers", lookup="user")
category_router = routers.NestedDefaultRouter(router, "categories", lookup="category")

user_router.register("orders", OrderViewSet, base_name="orders")
category_router.register("products", ProductViewSet, base_name="products")

Ejemplo n.º 25
0
app_name = "kubeops_api"
router = DefaultRouter()

router.register('clusters', api.ClusterViewSet, 'cluster')

# 注册离线包路由
router.register('packages', api.PackageViewSet, 'package')
router.register('credential', api.CredentialViewSet, 'credential')
router.register('host', api.HostViewSet, 'host')
router.register('setting', api.SettingViewSet, 'setting')
router.register('backupStorage', api.BackupStorageViewSet, 'backupStorage')
router.register('backupStrategy', api.BackupStrategyViewSet, 'backupStrategy')
router.register('clusterBackup', api.ClusterBackupViewSet, 'clusterBackup')

cluster_router = routers.NestedDefaultRouter(router, r'clusters', lookup='cluster')
cluster_router.register(r'configs', api.ClusterConfigViewSet, 'cluster-config')
cluster_router.register(r'nodes', api.NodeViewSet, 'cluster-node')
cluster_router.register(r'roles', api.RoleViewSet, 'cluster-role')
cluster_router.register(r'executions', api.DeployExecutionViewSet, 'cluster-deploy-execution')

urlpatterns = [
                  path('cluster/<uuid:pk>/download/', api.DownloadView.as_view()),
                  path('cluster/<uuid:pk>/token/', api.GetClusterTokenView.as_view()),
                  path('cluster/<uuid:pk>/webkubectl/token/', api.WebKubeCtrlToken.as_view()),
                  path('cluster/config', api.GetClusterConfigView.as_view()),
                  path('version/', api.VersionView.as_view()),
                  path('version/', api.VersionView.as_view()),
                  path('backupStorage/check', api.CheckStorageView.as_view()),
                  path('backupStorage/getBuckets', api.GetBucketsView.as_view()),
                  path('clusterBackup/<uuid:project_id>/', api.ClusterBackupList.as_view()),
Ejemplo n.º 26
0
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.urls import path, include
from rest_framework.routers import DefaultRouter
from .views import DebtorViewSet, TransactionViewSet, UserViewSet, RecaptchaAPIView
from rest_framework_nested import routers

router_v1 = DefaultRouter()
router_v1.register('debtor', DebtorViewSet, basename='debtor')
router_v1.register('user', UserViewSet, basename='user')
transaction_router = routers.NestedDefaultRouter(router_v1,
                                                 'debtor',
                                                 lookup='debtor')
transaction_router.register('transaction',
                            TransactionViewSet,
                            basename='debtor-transaction')

urlpatterns = [
    path('recaptcha-v3/', RecaptchaAPIView.as_view(), name='captcha'),
    path('v1/', include(router_v1.urls)),
    path('v1/', include(transaction_router.urls)),
    path('auth/', include('oauth2_provider.urls',
                          namespace='oauth2_provider')),
]
Ejemplo n.º 27
0
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
# from rest_framework import routers
from rest_framework.documentation import include_docs_urls
from rest_framework_nested import routers
from .myapp.apis import UserViewSet, GroupViewSet, MembershipViewSet

router = routers.DefaultRouter()
router.register('users', UserViewSet)
router.register('groups', GroupViewSet)
# router.register('groups/<int:group_pk>/', MembershipViewSet, base_name='membership')

# r2 = routers.DefaultRouter()
# r2.register('membership', MembershipViewSet, base_name='membership')
r2 = routers.NestedDefaultRouter(router, r'groups', lookup='group')
r2.register('membership', MembershipViewSet, base_name='membership')

urlpatterns = [
    path('admin/', admin.site.urls),
    path(r'docs/',
         include_docs_urls(title='My App API Docs', description='API接口')),
    path('', include(router.urls)),
    path('', include(r2.urls))
]
Ejemplo n.º 28
0
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from rest_framework_nested import routers

from school.views import SchoolModelViewSet, StudentModelViewSet

router = routers.DefaultRouter()
# Domain routes
router.register('schools', SchoolModelViewSet, basename='school')
router.register('students', StudentModelViewSet, basename='student')

# Nested routes
schools_router = routers.NestedDefaultRouter(router,
                                             'schools',
                                             lookup='school')
schools_router.register('students',
                        StudentModelViewSet,
                        basename='school-students')

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include(router.urls)),
    path('', include(schools_router.urls)),
]
Ejemplo n.º 29
0
from django.urls import path
from spells import views
from rest_framework_nested import routers

router = routers.DefaultRouter()
router.register(r'spells', views.SpellView, base_name='spells')
router.register(r'spellbooks', views.SpellbookView, base_name='spellbooks')

spellbooks_router = routers.NestedDefaultRouter(router,
                                                r'spellbooks',
                                                lookup='spellbook')
spellbooks_router.register(r'spells',
                           views.NestedSpellView,
                           base_name='spellbook-spells')

urls = [path('spellbook/<int:id>/pdf', views.SpellbookSpellPdf.as_view())]

urlpatterns = router.urls + spellbooks_router.urls + urls
Ejemplo n.º 30
0
from rest_framework_nested import routers as nested_router
from v1.landingpage.urls import router
from v1.db.views import LandingPageDBViewSets

companies_router = nested_router.NestedDefaultRouter(router,
                                                     r'landing_pages',
                                                     lookup='landing_page')
companies_router.register(r'landing_dbs',
                          LandingPageDBViewSets,
                          basename='landing-db')