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 django.conf import settings from rest_framework_nested.routers import DefaultRouter, NestedDefaultRouter from rest_framework_swagger.views import get_swagger_view from accounts.views import UserViewSets, MeView from evacuation.views import ShelterViewSets, EvacuationHistoryViewSets, EvacuationViewSets, DemoEvacuationHistoryViewSets from disaster.views import LocationView, DemoLocationView router = DefaultRouter() router.register(r'users', UserViewSets, basename='users') router.register(r'shelters', ShelterViewSets, basename='shelters') router.register(r'demo-shelters', ShelterViewSets, basename='demo-shelters') shelter_nested_router = NestedDefaultRouter(router, 'shelters', lookup='shelter') shelter_nested_router.register(r'history', EvacuationHistoryViewSets, basename='history') shelter_nested_router.register(r'evacuate', EvacuationViewSets, basename='evacuate') demo_shelter_nested_serializer = NestedDefaultRouter(router,
# -*- coding: utf-8 -*- from django.conf import settings from django.conf.urls import include, url from django.contrib import admin from rest_framework_nested.routers import DefaultRouter, NestedSimpleRouter from image_downloader import views api_v1_router = DefaultRouter() api_v1_router.register('job', views.JobViewSet, base_name='job') api_v1_job_router = NestedSimpleRouter(api_v1_router, 'job', lookup='job') api_v1_job_router.register('image', views.ImageInfoViewSet, base_name='image') urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'^api/v1/', include(api_v1_router.urls)), url(r'^api/v1/', include(api_v1_job_router.urls)), url(r'^docs/', include('rest_framework_swagger.urls')), ] if settings.DEBUG: urlpatterns += [ url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}) ]
from django.conf.urls import url, include from rest_framework_nested.routers import SimpleRouter, DefaultRouter, NestedSimpleRouter from score.views import ScoreViewSet, ScoreDataViewSet root_router = DefaultRouter() root_router.register('score', ScoreViewSet, 'score') root_router.register('score-data', ScoreDataViewSet, 'score-data') score_router = SimpleRouter() score_router.register('score', ScoreViewSet, base_name='list-score') score_data_router = NestedSimpleRouter(score_router, 'score', lookup='score') score_data_router.register('data', ScoreDataViewSet, base_name='list-score-data') urlpatterns = [ url(r'', include(root_router.urls)), url(r'list/', include(score_router.urls)), url(r'list/', include(score_data_router.urls)), ]
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.conf.urls import url from django.contrib import admin from django.urls import include, path from polls.views import PollViewSet, QuestionViewSet, interactive_hook from rest_framework_nested.routers import DefaultRouter, NestedSimpleRouter from rest_framework_simplejwt.views import ( TokenObtainPairView, TokenRefreshView, ) router = DefaultRouter() router.register(r'polls', PollViewSet) poll_router = NestedSimpleRouter(router, r'polls', lookup='poll') poll_router.register(r'questions', QuestionViewSet, basename='poll-questions') # urlpatterns = router.urls urlpatterns = ( # url(r'^', include(router.urls)), # url(r'^', include(poll_router.urls)), path('', admin.site.urls), # url('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'), # url('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'), path('event/hook/', interactive_hook, name='event_hook'), )
from geofluxus.apps.asmfa.views import ( ActivityGroupViewSet, ActivityViewSet, CompanyViewSet, ActorViewSet, ProcessGroupViewSet, ProcessViewSet, Waste02ViewSet, Waste04ViewSet, Waste06ViewSet, MaterialViewSet, AgendaViewSet, IndustryViewSet, ChainViewSet, GNcodeViewSet, TreatmentEmissionViewSet, YearViewSet, MonthViewSet, FlowChainViewSet, FlowViewSet, AdminLevelViewSet, AreaViewSet, AreaInLevelViewSet, DatasetTypeViewSet, DatasetViewSet, RoutingViewSet, WaysViewSet, VehicleViewSet) from geofluxus.apps.login.views import (UserFilterViewSet) from geofluxus.apps.analyse.views import ( MonitorViewSet, ) from geofluxus.apps.analyse.views import ( ImpactViewSet, ) from geofluxus.apps.fileshare.views import (SharedFileViewSet) router = DefaultRouter() # Datasets router.register(r'datasettypes', DatasetTypeViewSet) router.register(r'datasets', DatasetViewSet) # Areas router.register(r'levels', AdminLevelViewSet) router.register(r'allareas', AreaViewSet) # Network router.register(r'ways', WaysViewSet) router.register(r'vehicles', VehicleViewSet) # Nodes router.register(r'activitygroups', ActivityGroupViewSet)
from django.conf.urls import url from django.urls import include from rest_framework_nested.routers import DefaultRouter, NestedSimpleRouter from .views import VoteSubmitAPIView, VotesViewSet, QuestionResultsViewSet, FinishedVotesAPIView, ComingVotesAPIView votings_router = DefaultRouter() votings_router.register(r'api/votings/active', VotesViewSet, basename='voting') coming_votings_router = DefaultRouter() coming_votings_router.register(r'api/votings/coming', ComingVotesAPIView, basename='voting') finished_votings_router = DefaultRouter() finished_votings_router.register(r'api/votings/finished', FinishedVotesAPIView, basename='voting') vote_submit_router = NestedSimpleRouter(votings_router, r'api/votings/active', lookup='voting') vote_submit_router.register(r'vote', VoteSubmitAPIView, basename='vote') voting_results_router = NestedSimpleRouter(votings_router, r'api/votings/active', lookup='voting') voting_results_router.register(r'results', QuestionResultsViewSet, basename='results') voting_urlpatterns = [
from rest_framework_nested.routers import DefaultRouter, NestedDefaultRouter from . import views router = DefaultRouter() router.register('hot', views.HotArticleViewSet, base_name='hot-article') router.register('topic', views.TopicArticleViewSet, base_name='topic-article') router.register('archive', views.ArchiveViewSet, base_name='archive') router.register('', views.ArticleViewSet, base_name='article') article_router = NestedDefaultRouter(router, '', lookup='article') article_router.register(r'comment', views.ArticleCommentViewSet, base_name='article-comment') urlpatterns = [] urlpatterns += router.urls + article_router.urls
from django.conf.urls import url, include from rest_framework_nested.routers import SimpleRouter, DefaultRouter, NestedSimpleRouter from school.views import SchoolViewSet from classes.views import ClassesViewSet, SemesterViewSet from school.views import SchoolViewSet, SchoolClassesViewSet, SchoolClassesSemesterViewSet from student.views import StudentViewSet root_router = DefaultRouter() root_router.register('school', SchoolViewSet, 'school') school_router = SimpleRouter() school_router.register('school', SchoolViewSet, base_name='list-school') school_classes_router = NestedSimpleRouter(school_router, 'school', lookup='school') school_classes_router.register('classes', SchoolClassesViewSet, base_name='list-school-classes') school_classes_semester_router = NestedSimpleRouter(school_classes_router, 'classes', lookup='classes') school_classes_semester_router.register('semester', SchoolClassesSemesterViewSet, base_name='list-school-classes-semester') school_classes_student_router = NestedSimpleRouter(school_classes_router, 'classes', lookup='classes') school_classes_student_router.register('student', StudentViewSet, base_name='list-school-classes-student') urlpatterns = [ url(r'', include(root_router.urls)), url(r'list/', include(school_router.urls)), url(r'list/', include(school_classes_router.urls)), url(r'list/', include(school_classes_semester_router.urls)), url(r'list/', include(school_classes_student_router.urls)), ]
from django.urls import include from django.conf.urls import url from rest_framework_nested.routers import DefaultRouter, NestedSimpleRouter from .views import VotingCreatingViewSet, QuestionCreatingViewSet, ChoiceCreatingViewSet, VoterCreatingViewSet router = DefaultRouter() router.register(r'api/constructor', VotingCreatingViewSet, basename='votings') vote_router = NestedSimpleRouter(router, r'api/constructor', lookup='voting') vote_router.register(r'questions', QuestionCreatingViewSet, basename='questions') choice_router = NestedSimpleRouter(vote_router, r'questions', lookup='choice') choice_router.register(r'choices', ChoiceCreatingViewSet, basename='choices') voters_router = NestedSimpleRouter(router, r'api/constructor', lookup='voter') voters_router.register(r'voters', VoterCreatingViewSet, basename='voters') constructor_urlpatterns = [ url(r'^', include(router.urls)), url(r'^', include(voters_router.urls)), url(r'^', include(vote_router.urls)), url(r'^', include(choice_router.urls)), ]
from django.urls import path, include # from rest_framework.routers import DefaultRouter from rest_framework_nested.routers import DefaultRouter, NestedDefaultRouter from rest_framework_jwt.views import obtain_jwt_token, verify_jwt_token from link_generator.api_viewsets import ProjectViewSet, LinkPackViewSet, ChangePasswordViewSet # from . import views router = DefaultRouter() # router.register(r'projects/(?P<pid>[^/.]+)/linkpacks', LinkPackViewSet, base_name='linkpacks') # router.register(r'linkpacks', LinkPackViewSet, base_name='linkpacks') # router.register(r'projects/:project_id/linkpacks/', LinkPackViewSet, base_name='linkpacks') router.register(r'projects', ProjectViewSet) # router.register(r'change_password', ChangePasswordViewSet, base_name='change_password') # router.register(r'qqq', LinkSetViewSet, base_name='qqq') # router.register(r'users', UserViewSet) linkpack_router = NestedDefaultRouter(router, r'projects', lookup='project') linkpack_router.register(r'linkpacks', LinkPackViewSet, base_name='project-linkpacks') # linkset_router = NestedDefaultRouter(linkpack_router, r'linkpacks', lookup='linkpack') # linkset_router.register(r'linkset', LinkSetViewSet, base_name='project-linkpacks-linkset') urlpatterns = [ # path('', views.index, name='index'), path('change_password/', ChangePasswordViewSet.as_view()), path('', include(router.urls)),
from django.conf.urls import url, include from rest_framework_nested.routers import SimpleRouter, DefaultRouter, NestedSimpleRouter from common.views import CodeSubjectViewSet root_router = DefaultRouter() root_router.register('subject', CodeSubjectViewSet, 'code-subject') urlpatterns = [ url(r'', include(root_router.urls)), ]
from django.conf.urls import url, include from geofluxus.apps.asmfa.views import ( ActivityGroupViewSet, ActivityViewSet, CompanyViewSet, ActorViewSet, ProcessGroupViewSet, ProcessViewSet, Waste02ViewSet, Waste04ViewSet, Waste06ViewSet, TreatmentEmissionViewSet, MaterialViewSet, ProductViewSet, CompositeViewSet, YearViewSet, MonthViewSet, FlowChainViewSet, FlowViewSet, ClassificationViewSet, ExtraDescriptionViewSet, AdminLevelViewSet, AreaViewSet, AreaInLevelViewSet, DatasetTypeViewSet, DatasetViewSet, RoutingViewSet, WaysViewSet, VehicleViewSet) from geofluxus.apps.login.views import (UserFilterViewSet) from geofluxus.apps.analyse.views import ( MonitorViewSet, ) from geofluxus.apps.analyse.views import ( ImpactViewSet, ) router = DefaultRouter() # Datasets router.register(r'datasettypes', DatasetTypeViewSet) router.register(r'datasets', DatasetViewSet) # Areas router.register(r'levels', AdminLevelViewSet) router.register(r'allareas', AreaViewSet) # Network router.register(r'ways', WaysViewSet) router.register(r'vehicles', VehicleViewSet) # Nodes router.register(r'activitygroups', ActivityGroupViewSet)
from drf_yasg import openapi from drf_yasg.views import get_schema_view from tabulation.views import HatchViewSet schema_view = get_schema_view( openapi.Info( title="Broadcast Backend API", default_version="v1", description="Broadcast Backend API", ), public=True, permission_classes=(permissions.AllowAny, ), ) from rest_framework_nested.routers import DefaultRouter router = DefaultRouter() hatchviewupdate = HatchViewSet.as_view({'put': 'update'}) hatchviewlist = HatchViewSet.as_view({'get': 'list'}) hatchviewdetail = HatchViewSet.as_view({'get': 'retrieve'}) hatchviewcreate = HatchViewSet.as_view({'post': 'create'}) HatchViewfreelist = HatchViewSet.as_view({'get': 'free'}) urlpatterns = [ path('admin/', admin.site.urls), path("swagger/", schema_view.with_ui("swagger", cache_timeout=0), name="schema-swagger-ui"), path('hatchrecords/', hatchviewlist, name="hatchrecords"), path('hatchrecordsfree/', HatchViewfreelist, name="hatchrecords_free"), path('hatchrecords/<pk>/detail',
from rest_framework_nested.routers import DefaultRouter, NestedDefaultRouter from schools.views import SchoolViewSet from students.views import StudentViewSet router = DefaultRouter(trailing_slash=True) router.register('schools', SchoolViewSet, basename='school') router.register('students', StudentViewSet, basename='student') students_router = NestedDefaultRouter(router, 'schools', lookup='school') students_router.register('students', StudentViewSet, basename='school_students') urlpatterns = [] urlpatterns += router.urls urlpatterns += students_router.urls
from django.conf.urls import url, include from rest_framework_nested.routers import SimpleRouter, DefaultRouter, NestedSimpleRouter from school.views import SchoolViewSet from classes.views import ClassesViewSet, SemesterViewSet from school.views import SchoolViewSet, SchoolClassesViewSet, SchoolClassesSemesterViewSet from student.views import StudentViewSet root_router = DefaultRouter() root_router.register('school', SchoolViewSet, 'school') school_router = SimpleRouter() school_router.register('school', SchoolViewSet, base_name='list-school') school_classes_router = NestedSimpleRouter(school_router, 'school', lookup='school') school_classes_router.register('classes', SchoolClassesViewSet, base_name='list-school-classes') school_classes_semester_router = NestedSimpleRouter(school_classes_router, 'classes', lookup='classes') school_classes_semester_router.register( 'semester', SchoolClassesSemesterViewSet, base_name='list-school-classes-semester') school_classes_student_router = NestedSimpleRouter(school_classes_router, 'classes', lookup='classes') school_classes_student_router.register('student', StudentViewSet, base_name='list-school-classes-student')
from rest_framework_nested.routers import DefaultRouter from .views import UserView # User endpoint URL configuration router = DefaultRouter() router.register(r'', UserView) urlpatterns = [] urlpatterns += router.urls
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 include, path, re_path from rest_framework_nested.routers import DefaultRouter, NestedDefaultRouter from employees import views as employees_views from modules import views as modules_views from orders import views as orders_views from schedules import views as schedules_views from syllabus import views as syllabus_views from . import views router = DefaultRouter() router.register(r'degrees', employees_views.DegreeViewSet) # generates: # /degrees/ # /degrees/{pk} router.register(r'positions', employees_views.PositionViewSet) # generates: # /positions/ # /positions/{pk} router.register(r'employees', employees_views.EmployeeViewSet) # generates: # /employees/ # /employees/{abbreviation} router.register(r'schedules', schedules_views.SchedulesViewSet,
from django.conf.urls import url, include from rest_framework_nested.routers import SimpleRouter, DefaultRouter, NestedSimpleRouter from score.views import ScoreViewSet, ScoreDataViewSet root_router = DefaultRouter() root_router.register('score', ScoreViewSet, 'score') root_router.register('score-data', ScoreDataViewSet, 'score-data') score_router = SimpleRouter() score_router.register('score', ScoreViewSet, base_name='list-score') score_data_router = NestedSimpleRouter(score_router, 'score', lookup='score') score_data_router.register('data', ScoreDataViewSet, base_name='list-score-data') urlpatterns = [ url(r'', include(root_router.urls)), url(r'list/', include(score_router.urls)), url(r'list/', include(score_data_router.urls)), ]
from rest_framework_nested.routers import DefaultRouter from .views import StockView # Create your urls here router = DefaultRouter() router.register(r'', StockView) urlpatterns = [] urlpatterns += router.urls
from django.conf.urls import url from django.urls import path from django.urls import include from service.celery_views import VideoConversionStatus from .views import AssetViewSet, VideoStreamView, FrameViewSet, TelemetryViewSet, AnomalyViewSet, \ AnomalyPerMissionViewSet from .views import MissionViewSet from rest_framework_nested.routers import DefaultRouter from rest_framework_swagger.views import get_swagger_view router = DefaultRouter() router.register('assets', AssetViewSet, basename='assets') router.register(r'assets/(?P<asset_uuid>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/missions', MissionViewSet, basename='missions') router.register(r'assets/(?P<asset_uuid>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/missions/(?P<mission_uuid>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/video', VideoStreamView, basename='video') router.register(r'assets/(?P<asset_uuid>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/missions/(?P<mission_uuid>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/telemetry',TelemetryViewSet , basename='frame') router.register(r'assets/(?P<asset_uuid>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/missions/(?P<mission_uuid>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/frames', FrameViewSet, basename='telemetry') router.register(r'assets/(?P<asset_uuid>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/missions/(?P<mission_uuid>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/anomalies', AnomalyPerMissionViewSet, basename='mission_anomalies') router.register(r'assets/(?P<asset_uuid>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/missions/(?P<mission_uuid>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/frames/(?P<frame_uuid>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/anomalies', AnomalyViewSet, basename='anomaly') schema_view = get_swagger_view(title='SCIADRO API') urlpatterns = [ path('', include(router.urls)), url(r'swagger', schema_view), path('celery/status/<uuid:task_id>', VideoConversionStatus.as_view())
from django.urls import include, path from rest_framework_nested.routers import DefaultRouter, NestedSimpleRouter from .views import * router = DefaultRouter() router.register(r'cameras', CameraViewSet) router.register(r'cafeterias', CafeteriaViewSet) router.register(r'fixed_menu_reviews', FixedMenuOptionReviewViewSet) cafeterias_router = NestedSimpleRouter(router, r'cafeterias', lookup='cafeteria') cafeterias_router.register(r'fixed_menu_options', FixedMenuOptionViewSet, basename='cafeteria-fixed_menu_options') fixed_menu_options_router = NestedSimpleRouter(cafeterias_router, r'fixed_menu_options', lookup='option') fixed_menu_options_router.register( r'reviews', CafeteriaFixedMenuOptionReviewViewSet, basename='cafeteria-fixed_menu_options-review') cameras_router = NestedSimpleRouter(router, r'cameras', lookup='camera') cameras_router.register(r'events', CameraEventsViewSet, basename='camera_events') urlpatterns = [
from django.conf.urls import url, include from rest_framework_nested.routers import SimpleRouter, DefaultRouter, NestedSimpleRouter from classes.views import ClassesViewSet, SemesterViewSet from classes.views import ClassesSemesterViewSet from student.views import ClassesStudentViewSet root_router = DefaultRouter() root_router.register('classes', ClassesViewSet, 'classes') root_router.register('semester', SemesterViewSet, 'semester') classes_router = SimpleRouter() classes_router.register('classes', ClassesViewSet, base_name='list-classes') classes_semester_router = NestedSimpleRouter(classes_router, 'classes', lookup='classes') classes_semester_router.register('semester', ClassesSemesterViewSet, base_name='list-classes-semester') classes_student_router = NestedSimpleRouter(classes_router, 'classes', lookup='classes') classes_student_router.register('student', ClassesStudentViewSet, base_name='list-classes-student') urlpatterns = [ url(r'', include(root_router.urls)), url(r'list/', include(classes_router.urls)), url(r'list/', include(classes_semester_router.urls)), url(r'list/', include(classes_student_router.urls)), ]
ImpactCategoryInSustainabilityViewSet, AreaOfProtectionViewSet, TargetValueViewSet, TargetSpatialReferenceViewSet, FlowIndicatorViewSet, FlowFilterViewSet) from repair.apps.conclusions.views import (ConclusionViewSet, SectionViewSet, ConsensusViewSet) from repair.apps.utils.views import PublicationView from repair.apps.publications.views import ( PublicationInCasestudyViewSet, ) from repair.apps.wmsresources.views import ( WMSResourceInCasestudyViewSet, ) ## base routes ## router = DefaultRouter() router.register(r'casestudies', login_views.CaseStudyViewSet) router.register(r'keyflows', KeyflowViewSet) router.register(r'products', AllProductViewSet) router.register(r'wastes', AllWasteViewSet) router.register(r'materials', AllMaterialViewSet) router.register(r'publications', PublicationView) router.register(r'reasons', ReasonViewSet) router.register(r'sustainabilities', SustainabilityFieldViewSet) router.register(r'impactcategories', ImpactcategoryViewSet) router.register(r'targetvalues', TargetValueViewSet) router.register(r'targetspecialreference', TargetSpatialReferenceViewSet) router.register(r'areasofprotection', AreaOfProtectionViewSet) router.register(r'processes', ProcessViewSet) ## nested routes (see https://github.com/alanjds/drf-nested-routers) ##
from django.conf.urls import url, include from rest_framework_nested.routers import DefaultRouter from student.views import StudentViewSet root_router = DefaultRouter() root_router.register('student', StudentViewSet, 'student') urlpatterns = [ url(r'', include(root_router.urls)), ]