from django.urls import path, register_converter from . import converters, views register_converter(converters.DynamicConverter, 'dynamic') urlpatterns = [ path('dynamic/<dynamic:value>/', views.empty_view, name='dynamic'), ]
from django.urls import path,register_converter from . import views, converters register_converter(converters.FloatConverter,'float') app_name = 'initial' urlpatterns = [ path('',views.index, name='index'), path('getvalue', views.getValue, name='getvalue'), path('<float:pitch>/<float:roll>/<float:yaw>',views.saveCoord, name='save_coord'), path('<str:lalala>',views.teste,name='teste'), ]
from .views import CategoryListView, SpendingView, SpendingFilterFormView, SpendingFilterView from .views import CategoryGroupUpdateView, CategoryUpdateView from datetime import datetime class DateConverter: regex = '\d{4}-\d{2}-\d{2}' def to_python(self, value): return datetime.strptime(value, '%Y-%m-%d') def to_url(self, value): return value register_converter(DateConverter, 'yyyy') urlpatterns = [ path('', CategoryListView.as_view(), name='category-list'), path('update/group/<int:pk>/', CategoryGroupUpdateView.as_view(), name='category-group-update'), path('update/cat/<int:pk>/', CategoryUpdateView.as_view(), name='category-update'), path('spending/', SpendingView.as_view(), name='spending-list'), path('spending/<int:year>/<int:month>/', SpendingView.as_view(), name='spending-list'), path('spending/<int:year>/<int:month>/', SpendingView.as_view(),
1. Add an import: from my_app import views 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.contrib import admin from django.urls import path, re_path, include, register_converter from app01.urlconvert import MonConvert # 注册定义的url转换器 register_converter(MonConvert, "mm") from app01 import views urlpatterns = [ # path('admin/', admin.site.urls), # path('timer/', views.timer), # views.timer(request) # # path('login.html/',views.login,name="Log"), # 路由配置: 路径--------->视图函数 # # re_path(r'articles/2003/$', views.special_case_2003), # special_case_2003(request) # # re_path(r'^articles/([0-9]{4})/$', views.year_archive), # year_archive(request,2009)
except IndexError: slug = '' return { 'ordinals': [int(i) for i in ord_slug[0].split('.')], 'slug': slug } def to_url(self, value): ordinal_string = '.'.join(str(i) for i in value['ordinals']) slug = value.get('slug') if slug: return '{}-{}'.format(ordinal_string, slug) return ordinal_string register_converter(IdSlugConverter, 'idslug') register_converter(OrdinalSlugConverter, 'ordslug') # # URLs # # these patterns will have optional format suffixes added, like '.json' drf_urlpatterns = [ # annotations resource re_path(r'^resources/(?P<resource_id>\d+)/annotations$', views.annotations, name='annotations'), ] urlpatterns = format_suffix_patterns(drf_urlpatterns) + [ path('', views.index, name='index'),
from django.urls import include, path, register_converter from hines.core import converters from . import feeds, views register_converter(converters.FourDigitYearConverter, 'yyyy') register_converter(converters.TwoDigitMonthConverter, 'mm') register_converter(converters.TwoDigitDayConverter, 'dd') app_name = 'weblogs' urlpatterns = [ path('post-tag-autocomplete/', views.PostTagAutocomplete.as_view(), name='post_tag_autocomplete',), # 2001 version in a pop-up window: path('random-phil/', views.RandomPhilView.as_view(), {'set': '2001'}, name='random_phil_2001'), # 2002 version in the main window: path('random/', views.RandomPhilView.as_view(), {'set': '2002'}, name='random_phil_2002'), path( '<slug:blog_slug>/<yyyy:year>/<mm:month>/<dd:day>/<slug:post_slug>.php', views.PostRedirectView.as_view(), name='post_redirect'), # Same as above but with index.php instead. path( '<slug:blog_slug>/<yyyy:year>/<mm:month>/<dd:day>/<slug:post_slug>/index.php',
# Special case to handle the templateUrl attributes when we have # not used webpack to package them up p = os.path.join(os.getcwd(), 'resources/ts', request.path[1:]) if os.path.isfile(p): return django.views.static.serve(request, p, document_root='/') else: return index(request) class NegativeOrPositive: regex = '-?\d+' def to_python(self, value): return int(value) def to_url(self, value): return str(value) register_converter(NegativeOrPositive, 'negpos') urlpatterns = [ re_path(r'^$', index, name='index'), path('data/persona/list', persona.PersonaList.as_view()), path('data/persona/count', persona.PersonCount.as_view()), path('data/persona/<int:id>', persona.PersonaView.as_view()), path('data/persona/<int:id>/asserts', persona.PersonAsserts.as_view()), path('data/persona/<int:id>/asserts/count', persona.PersonAssertsCount.as_view()), path('data/places/list', places.PlaceList.as_view()), path('data/places/count', places.PlaceCount.as_view()), path('data/places/<int:id>', places.PlaceView.as_view()),
from django.urls import path, register_converter from rest_framework_simplejwt.views import TokenRefreshView from .views import OrganizationSignupAPIView, VolunteerSignupAPIView, \ VolunteerEventsAPIView, OrganizationEventsAPIView, ObtainTokenPairView, OrganizationAPIView, VolunteerAPIView, \ CheckEmailAPIView, VolunteerEventSignupAPIView, SearchEventsAPIView, OrganizationEventAPIView, \ OrganizationEmailVolunteers, CheckSignupAPIView, EventVolunteers, EventDetailAPIView, \ OrganizationEventUpdateAPIView, VolunteerOrganizationAPIView, VolunteerEventAPIView, InviteVolunteersAPIView, \ InviteAPIView, EventAPIView, ObtainDualAuthView, VolunteerUnratedEventsAPIView, RateEventAPIView, \ RecoverPasswordView, ResetPasswordView, ObtainSocialTokenPairView from .urlTokens.converter import TokenConverter register_converter(TokenConverter, "url_token") urlpatterns = [ path('token/', ObtainTokenPairView.as_view()), path('token/dualauth/', ObtainDualAuthView.as_view()), path('token/social/', ObtainSocialTokenPairView.as_view()), path('token/recover/', RecoverPasswordView.as_view()), path('token/recover/reset/', ResetPasswordView.as_view()), path('refresh/', TokenRefreshView.as_view(), name='token_refresh'), path('signup/organization/', OrganizationSignupAPIView.as_view()), path('signup/volunteer/', VolunteerSignupAPIView.as_view()), path('signup/checkemail/', CheckEmailAPIView.as_view()), path('volunteer/', VolunteerAPIView.as_view()), path('volunteer/events/', VolunteerEventsAPIView.as_view()), path('volunteer/events/unrated/', VolunteerUnratedEventsAPIView.as_view()), path('volunteer/event/<int:event_id>/', VolunteerEventAPIView.as_view()), path('organization/', OrganizationAPIView.as_view()), path('organization/<int:org_id>/', VolunteerOrganizationAPIView.as_view()),
# from rest_framework.routers import DefaultRouter # router = DefaultRouter() # router.register('workers', views.ViewSet_Workers) # router.register('projects', views.ViewSet_Projects) class NegativeIntConverter: regex = '-?\d+' def to_python(self, value): return int(value) def to_url(self, value): return '%d' % value register_converter(NegativeIntConverter, 'negint') urlpatterns = format_suffix_patterns([ path('config', views.Config.as_view(), name='config'), path('projects/<str:slug_project>/balance', views.get_balance, name='get_balance'), path('projects/<str:slug_project>/finances', views.Finances.as_view(), name='get_finances_for_project'), path('projects/<str:slug_project>/templates_worker_all', views.templates_worker_all, name='templates_worker_for_project_all'), path('projects/<str:slug_project>/templates_worker', views.Templates_Worker.as_view(), name='templates_for_project'), path('projects/<str:slug_project>/templates_worker/<int:id_template>', views.Template_Worker.as_view(), name='template_for_project'), path('projects/<str:slug_project>/templates_assignment_all', views.templates_assignment_all, name='templates_assignment_for_project_all'), path('projects/<str:slug_project>/templates_assignment', views.Templates_Assignment.as_view(), name='templates_assignment_for_project'), path('projects/<str:slug_project>/templates_assignment/<int:id_template>', views.Template_Assignment.as_view(), name='template_assignment_for_project'),
from django.urls import path, include, register_converter from . import views, converters from rest_framework import routers register_converter(converters.DataConverter, 'date') urlpatterns = [ path('order/items/<date:begin>/<date:final>/', views.orderItemByDate), ]
from django.urls import path, re_path, register_converter from . import views, converters register_converter(converters.IntConverter, 'myint') register_converter(converters.FourDigitYearConverter, 'yyyy') urlpatterns = [ path('', views.index), #re_path('(?P<year>[0-9]{4}).html',views.myyear,name='urlyear'), re_path('(?P<year>[0-9]{4}).html', views.myyear, name='urlyear'), ### 带变量的URL #path('<int:year>', views.year), # 只接收整数,其他类型返回404 #path('<int:year>/<str:name>', views.name), path('<yyyy:year>', views.years) ]
from django.contrib import admin from django.contrib.sitemaps import views as sitemaps_views from django.urls import include, path, re_path, register_converter from django.views.decorators.cache import cache_page from django.views.generic import RedirectView from cl.audio.sitemap import AudioSitemap from cl.lib.converters import BlankSlugConverter from cl.opinion_page.sitemap import DocketSitemap, OpinionSitemap from cl.people_db.sitemap import PersonSitemap from cl.search.models import SEARCH_TYPES from cl.simple_pages.sitemap import SimpleSitemap from cl.sitemap import cached_sitemap from cl.visualizations.sitemap import VizSitemap register_converter(BlankSlugConverter, "blank-slug") sitemaps = { SEARCH_TYPES.ORAL_ARGUMENT: AudioSitemap, SEARCH_TYPES.OPINION: OpinionSitemap, SEARCH_TYPES.RECAP: DocketSitemap, SEARCH_TYPES.PEOPLE: PersonSitemap, "visualizations": VizSitemap, "simple": SimpleSitemap, } urlpatterns = [ # Admin docs and site path("admin/", admin.site.urls), path("", include("cl.audio.urls")), path("", include("cl.opinion_page.urls")),
__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)" __license__ = "AGPL v3" from django.conf.urls import url from django.urls import path, register_converter from ontology.converters import AcademicFieldSlugConverter, SpecialtySlugConverter from submissions.constants import SUBMISSIONS_COMPLETE_REGEX from . import views from .converters import CollegeSlugConverter register_converter(AcademicFieldSlugConverter, 'acad_field') register_converter(SpecialtySlugConverter, 'specialty') register_converter(CollegeSlugConverter, 'college') app_name = 'colleges' urlpatterns = [ # Editorial Colleges: public view path('', views.CollegeListView.as_view(), name='colleges'), path('<college:college>', views.CollegeDetailView.as_view(), name='college_detail'), path('<college:college>/email_Fellows', views.email_College_Fellows, name='email_College_Fellows'), # Fellowships url(r'^fellowships/(?P<contributor_id>[0-9]+)/add/$', views.FellowshipCreateView.as_view(),
# # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. from django.conf.urls import url from django.urls import path, include, register_converter from nobinobi_core.functions import FourDigitConverter, TwoDigitConverter from rest_framework.routers import DefaultRouter from nobinobi_daily_follow_up import views from nobinobi_daily_follow_up.utils import IsoDateConverter from nobinobi_daily_follow_up.views import ClassroomJsonView app_name = 'nobinobi_daily_follow_up' register_converter(FourDigitConverter, 'yyyy') register_converter(TwoDigitConverter, 'mmdd') register_converter(IsoDateConverter, 'isodate') router = DefaultRouter() router.register(r'presence', views.PresenceViewSet, basename="api-presence") router.register(r'earlytroubleshooting', views.EarlyTroubleshootingViewSet, basename="api-earlytroubleshooting") urlpatterns = [ path('api/', include(router.urls)), path('api/presence/presence_by_weeks/<isodate:from_date>/<isodate:end_date>/', views.PresenceViewSet.as_view({ 'get': 'presence_by_weeks', }), name='api-presence-presence-by-weeks'), path('api/presence/presence_by_classroom/<isodate:date>/<int:classroom_id>/', views.PresenceClassroomDateViewSet.as_view({'get': 'list'}), name='api-presence-presence-by-classroom'), path('api/presence/presence_by_classroom_kindergarten/<isodate:date>/<int:classroom_id>/', views.PresenceKindergartenClassroomDateViewSet.as_view({'get': 'list'}), name='api-presence-by-classroom-kindergarten'), path('api/presence/presence_by_weeks_and_child/<uuid:child_pk>/<isodate:from_date>/<isodate:end_date>/',
from django.contrib.auth.decorators import permission_required from django.urls import path, register_converter from internal.converters import TermConverter from internal.views import TimeTableView, SignupView, TimeTableAdminView, TimeTableCreationView register_converter(TermConverter, "term") urlpatterns = [ path("hours", TimeTableView.as_view(), name="hours"), path("hours/admin", permission_required("internal.admin_office_hours")(TimeTableAdminView.as_view()), name="admin_hours"), path("hours/create", permission_required("internal.admin_office_hours")(TimeTableCreationView.as_view()), name="create_hours"), path("hours/<term:term>", TimeTableView.as_view(), name="hours"), path("hours/change/<int:pk>", SignupView.as_view(), name="change_hours"), ]
They are slightly different from the built `uuid` """ regex = r'[\w\d\-\.]+' def to_python(self, value): """Convert url to python value.""" return str(value) def to_url(self, value): """Convert python value into url, just a string.""" return value register_converter(TaskPatternConverter, 'task_pattern') urlpatterns = [ path('<task_pattern:task_id>/done/', views.is_task_successful, name='celery-is_task_successful'), path('<task_pattern:task_id>/status/', views.task_status, name='celery-task_status'), path('<task_pattern:group_id>/group/done/', views.is_group_successful, name='celery-is_group_successful'), path('<task_patern:group_id>/group/status/', views.group_status, name='celery-group_status'), ]
from django.urls import path, register_converter from _1327.documents import urls as document_urls from _1327.documents import views as document_views from _1327.main.utils import SlugWithSlashConverter from . import views app_name = "polls" register_converter(SlugWithSlashConverter, 'slugwithslash') urlpatterns = [ path("list", views.index, name="index"), path("<slugwithslash:title>/edit", document_views.edit, name="edit"), path("<slugwithslash:title>/admin-result", views.results_for_admin, name="results_for_admin"), ] urlpatterns.extend(document_urls.document_urlpatterns) urlpatterns.extend([ path("<slugwithslash:title>", document_views.view, name="view"), ])
from django.urls import path, register_converter from app.views import file_list, file_content from datetime import datetime class Converter: regex = '[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}' format = '%Y-%m-%d' def to_python(self, value: str) -> datetime: return datetime.strptime(value, self.format) def to_url(self, value: datetime) -> str: return value.strftime(self.format) register_converter(Converter, 'dt') urlpatterns = [ path('', file_list, name='file_list'), path('<dt:date>/', file_list, name='file_list'), path('file/<name>/', file_content, name='file_content') ]
from django.urls import path, register_converter from hines.core import converters from . import views register_converter(converters.WordCharacterConverter, 'word') app_name = 'pinboard' urlpatterns = [ path('', views.HomeView.as_view(), name='home'), path('tags/', views.TagListView.as_view(), name='tag_list'), # Pinboard tags can contain pretty much any punctuation character: path('tags/<str:slug>/', views.TagDetailView.as_view(), name='tag_detail'), path('<word:username>/<word:hash>/', views.BookmarkDetailView.as_view(), name='bookmark_detail'), ]
else: logger.info('Serving index.html instead of %s', request.path) return render(request, 'index.html', context=csrf(request)) class NegativeOrPositive: regex = '-?\d+' def to_python(self, value): return int(value) def to_url(self, value): return str(value) register_converter(NegativeOrPositive, 'negpos') urlpatterns = [ path('data/persona/list', persona.PersonaList.as_view()), path('data/persona/count', persona.PersonCount.as_view()), path('data/persona/<int:id>', persona.PersonaView.as_view()), path('data/persona/<int:id>/asserts', persona.PersonAsserts.as_view()), path('data/persona/<int:id>/asserts/count', persona.PersonAssertsCount.as_view()), path('data/places/list', places.PlaceList.as_view()), path('data/places/count', places.PlaceCount.as_view()), path('data/places/<int:id>', places.PlaceView.as_view()), path('data/places/<int:id>/asserts', places.PlaceAsserts.as_view()), path('data/places/<int:id>/asserts/count', places.PlaceAssertsCount.as_view()), path('data/sources/list', sources.SourcesList.as_view()),
from django.urls import path, register_converter from . import views, userpage from mygpo.users import converters register_converter(converters.UsernameConverter, 'username') urlpatterns = [ path('share/', views.overview, name='share'), path( 'share/subscriptions-public', views.set_token_public, kwargs={'public': True, 'token_name': 'subscriptions_token'}, name='subscriptions-public', ), path( 'share/subscriptions-private', views.set_token_public, kwargs={'public': False, 'token_name': 'subscriptions_token'}, name='subscriptions-private', ), path( 'share/favfeed-public', views.set_token_public, kwargs={'public': True, 'token_name': 'favorite_feeds_token'}, name='favfeed-public', ), path(
from . import feeds from . import views class DateConverter: regex = r"\d{4}-\d{2}-\d{2}" def to_python(self, value): return datetime.strptime(value, "%Y-%m-%d").date() def to_url(self, value): return value register_converter(DateConverter, "date") app_name = "calendar" urlpatterns = [ path("", views.IndexView.as_view(), name="index"), path("group/<int:pk>/", views.GroupDetailView.as_view(), name="group_detail"), path("location/<int:pk>/", views.LocationDetailView.as_view(), name="location_detail"), path("events/", views.EventListView.as_view(), name="event_list"), path("events/dashboard/", views.EventDashboard.as_view(), name="event_dashboard"),
class NegativeIntConverter: """URL converter - catch negative integers.""" regex = r"-?\d+" def to_python(self, value): """To python.""" return int(value) def to_url(self, value): """To url.""" return "%d" % value register_converter(NegativeIntConverter, "negint") router = DefaultRouter() router.register("employees", views.EmployeeViewSet) router.register("workdays", views.WorkDayViewSet) urlpatterns = [ path("", include(router.urls)), path("month/<negint:from_now>/", views.get_month, name="get_month"), path( "workdays_from_day/<int:day_id>/", views.get_workday_from_day_id, name="workdays_from_day", ), ]
from django.urls import path, register_converter from file_server.app.views import file_list, file_content from .converters import DateConverter register_converter(DateConverter, 'DC') urlpatterns = [ path('', file_list, name='file_list'), path('<DC:date>', file_list, name='file_list'), path('file_content/<name>', file_content, name='file_content'), ]
from django.urls import path, re_path, register_converter from django.conf.urls import url from .myconverters import CodeConverter from . import views app_name = "scoops" # Converter 등록 register_converter(CodeConverter, "mycode") urlpatterns = [ path('', views.index, name="index"), # url(r'(?P<word>[0-9a-zA-Z]{4})/$', views.test1), # url(r'(?P<word>\w{4})/$', views.test1, name="my1"), # re_path(r'(?P<word>[0-9a-zA-Z]{4})/$', views.test2), # url(r'(?P<word>[0-9a-zA-Z]{4})/(?P<second>[0-9a-zA-Z]{2})/$', views.test3), re_path(r'(?P<word>\w{4})/(?P<second>\w{2})/$', views.test4, name="my4"), # Path Converter 이용해서 패턴 정의 path('article/<int:year>/<int:month>/<slug:myname>', views.test6), # 사용자 정의 Converter 이용 path('article/<mycode:num>/', views.func7), ]
from django.urls import path from django.urls import register_converter from apptwo import views as apptwo_views from apptwo import converters register_converter(converters.TwoDigitDayConverter, 'dd') urlpatterns = [ path('djangorocks/', apptwo_views.djangorocks), path('pictures/<str:category>/', apptwo_views.picture_detail), path('pictures/<str:category>/<int:year>/', apptwo_views.picture_detail), path('pictures/<str:category>/<int:year>/<int:month>/', apptwo_views.picture_detail), path('pictures/<str:category>/<int:year>/<int:month>/<dd:day>/', apptwo_views.picture_detail), ]
from django.urls import path, register_converter from holes import views, converters register_converter(converters.ComponentHoleIDConverter, 'YYYY/D') urlpatterns = [ #HOLES path('holes/', views.HolesView.as_view()), path('holes/<YYYY/D:pk>/', views.HoleDetail.as_view(), name='hole-detail-view'), #COMPONENTS path('components/', views.ComponentsView.as_view()), path('components/<YYYY/D:pk>/', views.ComponentDetail.as_view()), path('components/<YYYY/D:pk>/holes/', views.ComponentDetailHoles.as_view()), ]
from datetime import datetime from django.urls import path, register_converter from app.views import file_list, file_content # Определите и зарегистрируйте конвертер для определения даты в урлах и наоборот урла по датам class DateConverter: regex = '[0-9]{4}-[0-9]{2}-[0-9]{2}' def to_python(self, value): return datetime.strptime(value, '%Y-%m-%d') def to_url(self, value: datetime) -> str: return value.strftime('%Y-%m-%d') register_converter(DateConverter, 'datetime') urlpatterns = [ # Определите схему урлов с привязкой к отображениям .views.file_list и .views.file_content path('', file_list, name='file_list'), path('<datetime:date>/', file_list, name='file_list'), path('file/<name>', file_content, name='file_content'), ]
from django.contrib import admin from django.urls import path, include, register_converter from rest_framework import routers from ExchangeRate.converts import FloatUrlParameterConverter from currency.views import CurrencyViewSet from rates.views import RateViewSet, date_updated from exchange.views import exchange register_converter(FloatUrlParameterConverter, 'float') router = routers.DefaultRouter() router.register(r'currency', CurrencyViewSet) router.register(r'rate', RateViewSet) urlpatterns = [ path('', include(router.urls)), path('exchange/<str:from_currency>/<str:to_currency>/<float:count>/', exchange), path('date/updated/', date_updated), path('admin/', admin.site.urls), ]
from django.urls import path, register_converter from P365.converters import UintWithoutZero from .views import CalendarView, DatesEventView, GetAllEventsView, DeleteEventView, UpdateCreateEventView app_name = 'calendar' register_converter(UintWithoutZero, 'uint_id') urlpatterns = [ path('', CalendarView.as_view(), name='view'), path('<uint_id:id>/dates_get/', DatesEventView.as_view(), name='dates_event'), path('get_all_events/', GetAllEventsView.as_view(), name='get_all_events'), path('delete_event/', DeleteEventView.as_view(), name='delete_event'), path('update_or_create_event/', UpdateCreateEventView.as_view(), name='update_event'), ]
from django.urls import path, register_converter from . import legacy, simple, advanced, advanced, subscriptions from .advanced import auth, lists, sync, updates, episode, settings from mygpo.users import converters from mygpo.usersettings.converters import ScopeConverter register_converter(converters.ClientUIDConverter, 'client-uid') register_converter(converters.UsernameConverter, 'username') register_converter(ScopeConverter, 'scope') urlpatterns = [ path('upload', legacy.upload), path('getlist', legacy.getlist), path('toplist.opml', simple.toplist, kwargs={'count': 50, 'format': 'opml'}), path( 'subscriptions/<username:username>/' '<client-uid:device_uid>.<str:format>', simple.subscriptions, ), path( 'subscriptions/<username:username>.<str:format>', simple.all_subscriptions, name='api-all-subscriptions', ), path('toplist/<int:count>.<str:format>', simple.toplist, name='toplist-opml'), path('search.<str:format>', simple.search), path( 'suggestions/<int:count>.<str:format>', simple.suggestions, name='suggestions-opml',
from django.urls import path, register_converter from . import views, converters register_converter(converters.ContainerNumberConverter, "AAAADDDDDDD") urlpatterns = [ path('', views.index, name='index'), path('<AAAADDDDDDD:container_number>', views.results, name="results"), path('search', views.search, name='search'), path('feedback', views.feedback, name='feedback'), ]
from django.urls import path, register_converter, include from .views import podcast, episode from mygpo.users import converters register_converter(converters.ClientUIDConverter, 'client-uid') podcast_uuid_patterns = [ path('subscribe', podcast.subscribe_id, name='subscribe-id'), path('subscribe/+all', podcast.subscribe_all_id, name='subscribe-all-id'), path( 'unsubscribe/<client-uid:device_uid>', podcast.unsubscribe_id, name='unsubscribe-id', ), path('unsubscribe/+all', podcast.unsubscribe_all_id, name='unsubscribe-all-id'), path('add-tag', podcast.add_tag_id, name='add-tag-id'), path('remove-tag', podcast.remove_tag_id, name='remove-tag-id'), path( 'set-public', podcast.set_public_id, name='podcast-public-id', kwargs={'public': True}, ), path( 'set-private', podcast.set_public_id, name='podcast-private-id', kwargs={'public': False},
from django.urls import path, register_converter from app.views import * from .converter import DtConverter # Определите и зарегистрируйте конвертер для определения даты в урлах и наоборот урла по датам register_converter(DtConverter, 'dtc') urlpatterns = [ path('', file_list, name='file_list'), path('<dtc:dt>/', file_list, name='file_list'), path('file_content/<name>/', file_content, name='file_content'), ]
Examples: Function views 1. Add an import: from my_app import views 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.contrib import admin from django.urls.converters import SlugConverter from sign import views from django.urls import register_converter, path, include register_converter(SlugConverter, 'eid') urlpatterns = [ path('admin/', admin.site.urls), path('index/', views.index), path('login_action/', views.login_action), path('event_manage/', views.event_manage), path('accounts/login/', views.index), path('search_name/', views.search_name), path('guest_manage/', views.guest_manage), path('logout/', views.logout), path('sign_index/<eid:eid>/', views.sign_index), path('sign_index_action/<eid:eid>/', views.sign_index_action), path('api/', include('sign.urls')) ]
from django.urls import path, register_converter from . import views, converters app_name = 'notif_mobile' register_converter(converters.UserTypeConverter, 'user-type') # https://support.google.com/webmasters/answer/76329?hl=en # TODO: dash over underscore urlpatterns = [ path(r'<user-type:user_type>/token/', views.FcmToken.as_view(), name="handler-fcm-token"), ]
from django.conf.urls import include, url from django.conf.urls.static import static from django.contrib import admin from django.contrib.contenttypes import views as contenttype_views from django.contrib.staticfiles.storage import staticfiles_storage from django.urls import register_converter from django.utils.translation import ugettext_lazy as _ from django.views.generic import RedirectView from django_simple_paginator.converter import PageConverter import search.views import template_dynamicloader.views import web.views register_converter(PageConverter, 'page') urlpatterns = [ url(r'^$', web.views.Home.as_view(), name='home'), url(r'^', include('linuxos.urls')), url(_(r'^login/'), include('allauth.urls')), url(_(r'^accounts/'), include('accounts.urls')), url(_(r'^article/'), include('article.urls')), url(_(r'^blog/'), include('blog.urls')), url(r'^blackhole/', include('blackhole.urls')), url(_(r'^comments/'), include('comments.urls')), url(r'^desktopy/', include('desktops.urls')), url(_(r'^forum/'), include('forum.urls')), #url(_(r'^maintenance/'), include('maintenance.urls')), url(_(r'^news/'), include('news.urls')),
from django.urls import path, register_converter from .converters import FourDigitYearConverter from . import views register_converter(FourDigitYearConverter, 'yyyy') app_name = 'shop' urlpatterns = [ path('archives/<yyyy:year>/', views.archives_year, name='archives_year'), path('', views.item_list, name='item_list'), path('<int:pk>/', views.item_detail, name='item_detail'), path('new/', views.item_new, name='item_new'), path('<int:pk>/edit/', views.item_edit, name='item_edit'), ]
from django.urls import path, register_converter from . import converters, views register_converter(converters.FloatConverter, 'float') urlpatterns = [ path('rate/<int:ct>/<pk>/<float:score>/', views.rate_object, name='ratings_rate_object'), path('unrate/<int:ct>/<pk>/', views.rate_object, {'add': False}, name='ratings_unrate_object'), ]
def to_url(self, value): return value class ImageIdConverter: regex = r'\d+' def to_python(self, value): return int(value) def to_url(self, value): return '{:05d}'.format(value) register_converter(BinPidConverter, 'pid') register_converter(ImageIdConverter, 'image_id') urlpatterns = [ ########################################################################################## # Main entry point URLs # Details of some of the more complex routes are described in a dedicated wiki document: # https://github.com/WHOIGit/ifcbdb/wiki/URL-routes-(development) ########################################################################################## # TODO: Handle trailing slashes # TODO: The slugs for the images need to be left padded with zeros path('', views.index), path('index.html', views.index), path('dashboard', views.datasets, name='datasets'), path('timeline', views.timeline_page, name='timeline_page'),
from django.urls import path, re_path, register_converter from . import views, converters register_converter(converters.SignedIntConverter, 'sint') urlpatterns = [ path('', views.home, name='home'), path('cfp/', views.proposal_home, name='proposal-home'), path('cfp/token/', views.proposal_mail_token, name='proposal-mail-token'), re_path(r'^cfp/(?:(?P<speaker_token>[\w\-]+)/)?dashboard/$', views.proposal_dashboard, name='proposal-dashboard'), re_path(r'^cfp/(?:(?P<speaker_token>[\w\-]+)/)?profile/$', views.proposal_speaker_edit, name='proposal-profile-edit'), re_path(r'^cfp/(?:(?P<speaker_token>[\w\-]+)/)?talk/add/$', views.proposal_talk_edit, name='proposal-talk-add'), re_path(r'^cfp/(?:(?P<speaker_token>[\w\-]+)/)?talk/(?P<talk_id>[0-9]+)/$', views.proposal_talk_details, name='proposal-talk-details'), re_path(r'^cfp/(?:(?P<speaker_token>[\w\-]+)/)?talk/(?P<talk_id>[0-9]+)/edit/$', views.proposal_talk_edit, name='proposal-talk-edit'), re_path(r'^cfp/(?:(?P<speaker_token>[\w\-]+)/)?talk/(?P<talk_id>[0-9]+)/speaker/add/$', views.proposal_speaker_edit, name='proposal-speaker-add'), re_path(r'^cfp/(?:(?P<speaker_token>[\w\-]+)/)?talk/(?P<talk_id>[0-9]+)/speaker/add/(?P<speaker_id>[0-9]+)/$', views.proposal_speaker_add, name='proposal-speaker-add-existing'), #re_path(r'^cfp(?:/(?P<speaker_token>[\w\-]+))?/talk/(?P<talk_id>[0-9]+)/speaker/(?P<co_speaker_id>[0-9]+)/$', views.proposal_speaker_details, name='proposal-speaker-details'), re_path(r'^cfp/(?:(?P<speaker_token>[\w\-]+)/)?talk/(?P<talk_id>[0-9]+)/speaker/(?P<co_speaker_id>[0-9]+)/edit/$', views.proposal_speaker_edit, name='proposal-speaker-edit'), re_path(r'^cfp/(?:(?P<speaker_token>[\w\-]+)/)?talk/(?P<talk_id>[0-9]+)/speaker/(?P<co_speaker_id>[0-9]+)/remove/$', views.proposal_speaker_remove, name='proposal-speaker-remove'), re_path(r'^cfp/(?:(?P<speaker_token>[\w\-]+)/)?talk/(?P<talk_id>[0-9]+)/confirm/$', views.proposal_talk_acknowledgment, {'confirm': True}, name='proposal-talk-confirm'), re_path(r'^cfp/(?:(?P<speaker_token>[\w\-]+)/)?talk/(?P<talk_id>[0-9]+)/desist/$', views.proposal_talk_acknowledgment, {'confirm': False}, name='proposal-talk-desist'), path('volunteer/enrole', views.volunteer_enrole, name='volunteer-enrole'), path('volunteer/token/', views.volunteer_mail_token, name='volunteer-mail-token'), re_path(r'^volunteer/(?:(?P<volunteer_token>[\w\-]+)/)?$', views.volunteer_dashboard, name='volunteer-dashboard'), re_path(r'^volunteer/(?:(?P<volunteer_token>[\w\-]+)/)?profile/$', views.volunteer_profile, name='volunteer-profile-edit'), re_path(r'^volunteer/(?:(?P<volunteer_token>[\w\-]+)/)?join/(?P<activity>[\w\-]+)/$', views.volunteer_update_activity, {'join': True}, name='volunteer-join'), re_path(r'^volunteer/(?:(?P<volunteer_token>[\w\-]+)/)?quit/(?P<activity>[\w\-]+)/$', views.volunteer_update_activity, {'join': False}, name='volunteer-quit'), path('staff/', views.staff, name='staff'),
from django.conf import settings from django.conf.urls.static import static from django.contrib import admin from django.urls import include, path, register_converter from apps.common import converters as common_converters from apps.users import views register_converter(common_converters.ULIDConverter, "ulid") app_name = "apps.users" urlpatterns = [ path("", views.IndexView.as_view(), name="users_index"), ]
from django.urls import include, path, register_converter from . import converters, views register_converter(converters.Base64Converter, 'base64') subsubpatterns = [ path('<base64:last_value>/', views.empty_view, name='subsubpattern-base64'), ] subpatterns = [ path('<base64:value>/', views.empty_view, name='subpattern-base64'), path( '<base64:value>/', include((subsubpatterns, 'second-layer-namespaced-base64'), 'instance-ns-base64') ), ] urlpatterns = [ path('base64/<base64:value>/', views.empty_view, name='base64'), path('base64/<base64:base>/subpatterns/', include(subpatterns)), path('base64/<base64:base>/namespaced/', include((subpatterns, 'namespaced-base64'))), ]
shame, shame_by_state ) class StateConverter: regex = '[\w]{2}' def to_python(self, value): return value.lower() def to_url(self, value): return value register_converter(StateConverter, 'state') app_name = 'api' urlpatterns = [ path('', home, name='home'), path('fame/', fame, name='fame'), path('shame/', shame, name='shame'), path('<state:abbr>/', by_state, name='by_state'), path('<state:abbr>/fame/', fame_by_state, name='fame_by_state'), path('<state:abbr>/shame/', shame_by_state, name='shame_by_state'), path('provider/new/', provider_new, name='new'), path('provider/<int:pk>/', provider, name='provider'), ]