def setUp(self): # Patterns with a "catch all" view (thing) at the end. self.patterns_catchall = urlresolvers.URLResolver(RegexPattern(r'^/'), [ multiurl( url(r'^(\w+)/$', person, name='person'), url(r'^(\w+)/$', place, name='place'), url(r'^(\w+)/$', thing, name='thing'), ) ]) self.patterns_pathall = urlresolvers.URLResolver(RegexPattern(r'^/'), i18n_patterns( multiurl( path('<str:name>/', brand, name='brand'), path('<str:name>/', model, name='model'), ), )) # Patterns with no "catch all" - last view could still raise ContinueResolving. self.patterns_no_fallthrough = urlresolvers.URLResolver(RegexPattern(r'^/'), [ multiurl( url(r'^(\w+)/$', person, name='person'), url(r'^(\w+)/$', place, name='place'), ) ])
def setUp(self): # Patterns with a "catch all" view (thing) at the end. self.patterns_catchall = RegexURLResolver('^/', patterns('', multiurl( url(r'^(\w+)/$', person, name='person'), url(r'^(\w+)/$', place, name='place'), url(r'^(\w+)/$', thing, name='thing'), ) )) # Patterns with no "catch all" - last view could still raise ContinueResolving. self.patterns_no_fallthrough = RegexURLResolver('^/', patterns('', multiurl( url(r'^(\w+)/$', person, name='person'), url(r'^(\w+)/$', place, name='place'), ) ))
def add_product_category_url(urls): for url in urls.url_patterns: if isinstance(url, RegexURLResolver): add_product_category_url(url) elif isinstance(url, RegexURLPattern) and url.name == 'page': # category_product url is almost a catch all, so it needs to go # last. using multiurl, if it fails to find a product, then we # will go to the catch-all page url pageurl = urls.url_patterns.pop() urls.url_patterns.append( multiurl(create_url( "^(?P<category_slug>.+)/(?P<slug>.+)%s$" % _slash, views.category_product, name="shop_category_product"), pageurl, catch=(Http404, ContinueResolving))) return
from django.conf.urls import url from . import views from multiurl import multiurl app_name = 'investimento' urlpatterns = [ multiurl( url(r'^', views.investimento, name='investimento'), url(r'^', views.resgatar, name='resgate'), ) ]
from django.http import HttpResponse urlpatterns = [ re_path(r'^i18n/', include('django.conf.urls.i18n')), path('admin/', admin.site.urls), path('admin/auth/', include('django.contrib.auth.urls')), path('robots.txt', robots_txt, name='robots_txt'), path('sitemap.xml', sitemap, sitemap_view(), name='django.contrib.sitemaps.views.sitemap'), re_path(r'^_nested_admin/', include('nested_admin.urls')), path('ckeditor/', include('ckeditor_uploader.urls')), path('api/v1/', include('api.urls')), re_path( r'^cmsmagazine8dbc8898b2f57ed5aa99f9b830172491\.txt', lambda x: HttpResponse("8dbc8898b2f57ed5aa99f9b830172491", content_type="text/plain; charset=utf8")), ] urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += [ re_path(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}), ] urlpatterns += i18n_patterns( multiurl(catch=(Http404, ContinueResolving), ), prefix_default_language=settings.USE_DEFAULT_LANGUAGE_PREFIX, )
from django.conf.urls import patterns, url from django.http import Http404 from multiurl import ContinueResolving, multiurl from .views import (AlbumDetailView, SingleDetailView, TrackDetailView, TrackLyricsView) urlpatterns = patterns('', # MultiURL allows us to unite all of the music under a simpler URL. multiurl( url(r'^music/(?P<slug>[-\w]+)/$', name='single-detail', view=SingleDetailView.as_view()), url(r'^music/(?P<slug>[-\w]+)/$', name='album-detail', view=AlbumDetailView.as_view()), catch=(Http404, ContinueResolving) ), # url(r'^music/albums/$', name='album-browse', view=AlbumBrowseView.as_view()), # url(r'^music/singles/$', name='single-browse', view=SingleBrowseView.as_view()), url(r'^music/tracks/(?P<slug>[-\w]+)/lyrics/$', name='track-lyrics-detail', view=TrackLyricsView.as_view()), url(r'^music/tracks/(?P<slug>[-\w]+)/$', name='track-detail', view=TrackDetailView.as_view()), # url(r'^music/tracks/$', name='track-browse', view=TrackBrowseView.as_view()), # url(r'^music/$', name='music-browse', view=MusicBrowseView.as_view()), )
f'{settings.API_URL}/auth/', include(('garpix_auth.urls', 'garpix_auth'), namespace='garpix_auth')), path(f'{settings.API_URL}/page_models_list/', PageApiListView.as_view()), ] if settings.DEBUG: urlpatterns += [ path(f'{settings.API_URL}/schema/', SpectacularAPIView.as_view(), name='schema'), path(f'{settings.API_URL}/docs/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'), ] urlpatterns += static( settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + static( settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += i18n_patterns( multiurl( path('', PageView.as_view()), re_path(r'^(?P<url>.*?)$', PageView.as_view(), name='page'), re_path(r'^(?P<url>.*?)/$', PageView.as_view(), name='page'), path('', IndexView.as_view()), catch=(Http404, ContinueResolving), ), prefix_default_language=settings.USE_DEFAULT_LANGUAGE_PREFIX, )
from django.conf.urls import patterns, url from django.http import Http404 from multiurl import ContinueResolving, multiurl from .views import VideodiscDetailView urlpatterns = patterns('', # MultiURL allows us to unite all of the media under a simpler URL. multiurl( url(r'^discs/(?P<slug>[-\w]+)/$', name='videodisc-detail', view=VideodiscDetailView.as_view()), catch=(Http404, ContinueResolving) ), )
from django.conf.urls import patterns, url from django.http import Http404 from multiurl import ContinueResolving, multiurl from .views import GroupDetailView, IdolDetailView urlpatterns = patterns('', # MultiURL allows us to unite all of the people under a simpler URL. multiurl( url(r'^(?P<slug>[-\w]+)/$', name='idol-detail', view=IdolDetailView.as_view()), url(r'^(?P<slug>[-\w]+)/$', name='group-detail', view=GroupDetailView.as_view()), catch=(Http404, ContinueResolving) ), # url(r'^staff/(?P<slug>[-\w]+)/$', name='staff-detail', view=StaffDetailView.as_view()), # url(r'^groups/$', name='group-browse', view=GroupBrowseView.as_view()), # url(r'^idols/$', name='idol-browse', view=IdolBrowseView.as_view()), # url(r'^staff/$', name='staff-browse', view=StaffBrowseView.as_view()), )
from multiurl import multiurl, ContinueResolving admin.autodiscover() # Examples: # url(r'^$', 'bookies.views.home', name='home'), # url(r'^blog/', include('blog.urls')), url_list = [] # for each installed app, append the list of urls # this avoids every app having to appear in a sub-folder from bookies.settings import INSTALLED_APPS for app_name in INSTALLED_APPS: try: app = __import__(app_name, fromlist=['urls']) url_list = url_list + app.urls.urlpatterns except AttributeError: pass # use multiurl so that if any view raises a 404, any other view that # matches the same url pattern can be called until a 404 is not raised # this allows multiple views to use the same url pattern url_list = multiurl(*url_list, catch = (Http404, ContinueResolving)) # add on the call to static() to enabled uploaded images to work on dev (Debug = True) # on live the web server will be configured to serve the media folder statically urlpatterns = patterns('', url(r'^admin/', include(admin.site.urls)), url_list) + \ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) handler404 = 'django.views.defaults.page_not_found'
from django.conf.urls import url from multiurl import multiurl from documentation import views urlpatterns = [ multiurl( # url(r'^$', views.index, name='home'), url(r'^(?P<slug>[-\w]+)/$', views.ide_view, name='ide_view'), url(r'^(?P<ide_slug>[-\w]+)/(?P<slug>[-\w.]+)/$', views.block_view, name='block_view'), url(r'^(?P<ide_slug>[-\w]+)/(?P<slug>[-\w.]+)/embed/$', views.embed_view, name='embed_view'), url(r'^(?P<curric_slug>[-\w]+)/$', views.maps_view, name='maps_view'), url(r'^(?P<curric_slug>[-\w]+)/(?P<slug>[-\w.]+)/$', views.page_view, name='page_view'), ) ]