def urlpatterns_maker(**kwargs): path_init = inspect.getouterframes(inspect.currentframe())[1][1] path_views, file_name_init = os.path.split(path_init) path_app, folder_name_views = os.path.split(path_views) app_name = os.path.split(path_app)[1] files = [f.split('.')[0] for f in os.listdir(path_views) if not f.startswith('_') and (f.endswith('.py') or os.path.isdir(os.path.join(path_views, f))) and file_name_init != f] path_list = path_init.split('/') views_index = path_list.index('views') prefix = '.'.join(path_list[views_index-1:-1]) # print(path_init) # print(file_name_init) # print(path_views) # print(path_app) # print(folder_name_views) # print(app_name) # print(files) urlpatterns = [] for file_name in files: if file_name in kwargs: urlpatterns.append( url(r'{0}'.format(kwargs[file_name]), include('{0}.{1}'.format(prefix, file_name))) ) else: urlpatterns.append( url(r'^{0}/'.format(file_name), include('{0}.{1}'.format(prefix, file_name))) ) for urlpattern in urlpatterns: urlpattern.regex # url pattern check, thanks to django return urlpatterns
def get_admin_urls(self): urlpatterns = patterns('', (r'^dashboard/', include(self.dashboard_app.urls)), # paypal express is included in the dashboard app but including it again because urls in paypal templates are not scoped to dashboard: (r'^dashboard/express/', include(express_app.urls)), ) return urlpatterns
def _install_admin_urls(self, extension): """Installs administration URLs. This provides URLs for configuring an extension, plus any additional admin urlpatterns that the extension provides. """ prefix = self.get_absolute_url() if hasattr(settings, 'SITE_ROOT'): prefix = prefix[len(settings.SITE_ROOT):] # Note that we're adding to the resolve list on the root of the # install, and prefixing it with the admin extensions path. # The reason we're not just making this a child of our extensions # urlconf is that everything in there gets passed an # extension_manager variable, and we don't want to force extensions # to handle this. if extension.is_configurable: urlconf = extension.admin_urlconf if hasattr(urlconf, "urlpatterns"): extension.admin_urlpatterns = patterns('', (r'^%s%s/config/' % (prefix, extension.id), include(urlconf.__name__))) self.dynamic_urls.add_patterns( extension.admin_urlpatterns) if extension.has_admin_site: extension.admin_site_urlpatterns = patterns('', (r'^%s%s/db/' % (prefix, extension.id), include(extension.admin_site.urls))) self.dynamic_urls.add_patterns( extension.admin_site_urlpatterns)
def www_urlpattens(self): from django.conf.urls import patterns, url, include collection_patterns = patterns('', url(r'^$', self.variant_details, name='%s_variant_details' % self.name), url(r'^/toc$', self.table_of_contents, name='%s_table_of_contents' % self.name), url(r'^/m/(?P<module_id>\w+)$', self.reader, name='%s_module_reader' % self.name), url(r'^/m/(?P<module_id>\w+)/license$', self.license, name='%s_license' % self.name), url(r'^/m/(?P<module_id>\w+)/curriculum$', self.curriculum, name='%s_curriculum' % self.name), url(r'^/m/(?P<module_id>\w+)/contact$', self.contact, name='%s_contact' % self.name), url(r'^/m/(?P<module_id>\w+)/auto$', self.wrap_collection_reader('collection_not_ready.html')(womireader.AutonomicWomiReader.as_view(use_version=self.use_womi_version, config=self.config)), name='%s_autonomic_womi_reader' % self.name), url(r'^/volatile/(?P<module_id>\w+)$', self.volatile_module, name='%s_volatile_module' % self.name), ) if settings.EPO_ENABLE_TESTS: collection_patterns += patterns('', url(r'^/m/(?P<module_id>\w+)/test$', self.wrap_collection_reader('collection_not_ready.html')(CollectionReader.as_view(endpoints=self.endpoints, use_test=True, template_name=self.reader_template)), name='%s_module_reader_test' % self.name)) return patterns('', url(r'^c/(?P<collection_id>\w+)/v/(?P<version>\w+)/t/(?P<variant>(\w|-)+)', include(collection_patterns)), url(r'^m/(?P<module_id>\w+)/v/(?P<version>\d+)', include(patterns('', url(r'^/dependencies$', self.module_dependencies, name=self.config.view_name('module_dependencies')), url(r'^/womis$', self.module_womis, name=self.config.view_name('module_womis')), ))), url(r'^w/(?P<womi_id>\w+)/v/(?P<version>\d+)', include(patterns('', url('^/technical$', self.womi_technical, name='%s_womi_technical' % self.name), url('^/embed$', self.womi_embed, name='%s_womi_embed' % self.name), url('^/aggregate$', self.womi_aggregate, name='%s_womi_aggregate' % self.name), url('^$', self.womi_show, name='%s_womi_show' % self.name), ))), )
def urls(self): from django.conf.urls import include, url return self.make_urlconf( url('^api/', include(self.api.urls)), url('^api/', include(self.api2.urls)), )
def patterns(self, flat=False): urlpatterns = [url(r"^$", self.index)] + [ url(r"^%s/" % name, include(child.patterns(self.name))) for name, child in self.children.items() ] if flat: return urlpatterns return [url(r"^%s/" % self.name, include(urlpatterns))]
def build_urls(self): router = routers.DefaultRouter() router.register(r'repositories', self.RepositoryViewSet, base_name='{0}_repository'.format(self.view_prefix)) router.register(r'external_dependencies', self.ExternalDependencyViewSet, base_name='{0}_externaldependency'.format(self.view_prefix)) router.register(r'sources', self.PackageSourceViewSet, base_name='{0}_packagesource'.format(self.view_prefix)) router.register(r'builds', self.BuildViewSet, base_name='{0}_buildrecord'.format(self.view_prefix)) router.register(r'mirrors', self.MirrorViewSet, base_name='{0}_mirror'.format(self.view_prefix)) router.register(r'mirror_sets', self.MirrorSetViewSet, base_name='{0}_mirrorset'.format(self.view_prefix)) router.register(r'snapshots', self.SnapshotViewSet, base_name='{0}_snapshot'.format(self.view_prefix)) source_router = routers.NestedSimpleRouter(router, r'sources', lookup='source') source_router.register(r'builds', self.BuildViewSet, base_name='{0}_build'.format(self.view_prefix)) repository_router = routers.NestedSimpleRouter(router, r'repositories', lookup='repository') repository_router.register(r'sources', self.PackageSourceViewSet, base_name='{0}_packagesource'.format(self.view_prefix)) repository_router.register(r'external_dependencies', self.ExternalDependencyViewSet, base_name='{0}_externaldependency'.format(self.view_prefix)) urls = [url(r'^', include(router.urls)), url(r'^', include(repository_router.urls)), url(r'^', include(source_router.urls)), url(r'^auth/', include('rest_auth.urls')), url(r'^auth/github/$', GithubLogin.as_view(), name='github_login')] if getattr(settings, 'SIGNUP_OPEN', False): urls += [url(r'^auth/registration/', include('rest_auth.registration.urls'))] return urls
def get_versioned_urls(apps): """Generates a list of URL patterns for applications with REST APIs :param apps: A list of application names to register. :type apps: list[string] :returns: A list of URL patterns for REST APIs with version prefixes. :rtype: list[:class:`django.core.urlresolvers.RegexURLPattern`] """ urls = [] # TODO Remove the default version once applications are migrated for app in apps: urls.append(url(r'', include(app + '.urls'))) # Check whether the application is configured to use versions rest_settings = getattr(settings, 'REST_FRAMEWORK', None) if not rest_settings: return urls allowed_versions = rest_settings.get('ALLOWED_VERSIONS', None) if not allowed_versions: return urls # Generate a URL pattern for each endpoint with a version prefix for version in allowed_versions: version_urls = [] for app in apps: version_urls.append(url(r'^' + version + '/', include(app + '.urls', namespace=version))) urls.extend(version_urls) return urls
def get_urls(self): urls = super(StoreFR, self).get_urls() urls.append( url(r'^dashboard/paypal/express/', include(express_dashboard.urls))) urls.append(url(r'^checkout/paypal/', include('paypal.express.urls'))) return urls
def clients_support_urls(): urls = url('^clients_support/', include(router.urls)), if settings.INCLUDE_AUTOCOMPLETE_LIGHT_URLS: urls += url(r'^autocomplete/', include('autocomplete_light.urls')), return urls
def _decorated_urls(self): urlpatterns = self._get_default_urlpatterns() default_panel = None # Add in each panel's views except for the default view. for panel in self._registry.values(): if panel.slug == self.default_panel: default_panel = panel continue url_slug = panel.slug.replace('.', '/') urlpatterns += patterns('', url(r'^%s/' % url_slug, include(panel._decorated_urls))) # Now the default view, which should come last if not default_panel: raise NotRegistered('The default panel "%s" is not registered.' % self.default_panel) urlpatterns += patterns('', url(r'', include(default_panel._decorated_urls))) # Require login if not public. if not self.public: _decorate_urlconf(urlpatterns, require_auth) # Apply access controls to all views in the patterns permissions = getattr(self, 'permissions', []) _decorate_urlconf(urlpatterns, require_perms, permissions) _decorate_urlconf(urlpatterns, _current_component, dashboard=self) # Return the three arguments to django.conf.urls.include return urlpatterns, self.slug, self.slug
def get_urls(self): urlpatterns = patterns('', (r'^i18n/', include('django.conf.urls.i18n')), (r'^clienti/', include(self.cliente_app.urls)), # Password reset - as we're using Django's default view functions, # we can't namespace these urls as that prevents # the reverse function from working. # url(r'^password-reset/$', # login_forbidden(auth_views.password_reset), # {'password_reset_form': forms.PasswordResetForm, # 'post_reset_redirect': reverse_lazy('password-reset-done')}, # name='password-reset'), # url(r'^password-reset/done/$', # login_forbidden(auth_views.password_reset_done), # name='password-reset-done'), # url(r'^password-reset/confirm/(?P<uidb36>[0-9A-Za-z]{1,13})-(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', # login_forbidden(auth_views.password_reset_confirm), # {'post_reset_redirect': reverse_lazy('password-reset-complete')}, # name='password-reset-confirm'), # url(r'^password-reset/complete/$', # login_forbidden(auth_views.password_reset_complete), # name='password-reset-complete'), # (r'', include(self.promotions_app.urls)), ) return urlpatterns
def test_flatten_url_tree_url_import_with_routers(self): class MockApiViewSet(ModelViewSet): serializer_class = CommentSerializer model = User class AnotherMockApiViewSet(ModelViewSet): serializer_class = CommentSerializer model = User router = DefaultRouter() router.register(r'other_views', MockApiViewSet) router.register(r'more_views', MockApiViewSet) urls_app = patterns('', url(r'^', include(router.urls))) urls = patterns( '', url(r'api/', include(urls_app)), url(r'test/', include(urls_app)) ) urlparser = UrlParser() apis = urlparser.get_apis(urls) self.assertEqual(sum(api['path'].find('api') != -1 for api in apis), 4) self.assertEqual(sum(api['path'].find('test') != -1 for api in apis), 4)
def test_included_urls_django2_mixed_args(self): nested_patterns = [ path('path/<int:child>', dummy_view), url('^url/(?P<child>[0-9]+)$', dummy_view) ] urlpatterns = [ url('^purl/(?P<parent>[0-9]+)/', include(nested_patterns), {'foo': 'bar'}), path('ppath/<int:parent>/', include(nested_patterns), {'foo': 'bar'}), ] test_paths = [ # parent url() nesting child path() URLTestPath('/purl/87/path/42', (), {'parent': '87', 'child': 42, 'foo': 'bar', }), URLTestPath('/purl/87/path/42.api', (), {'parent': '87', 'child': 42, 'foo': 'bar', 'format': 'api'}), URLTestPath('/purl/87/path/42.asdf', (), {'parent': '87', 'child': 42, 'foo': 'bar', 'format': 'asdf'}), # parent path() nesting child url() URLTestPath('/ppath/87/url/42', (), {'parent': 87, 'child': '42', 'foo': 'bar', }), URLTestPath('/ppath/87/url/42.api', (), {'parent': 87, 'child': '42', 'foo': 'bar', 'format': 'api'}), URLTestPath('/ppath/87/url/42.asdf', (), {'parent': 87, 'child': '42', 'foo': 'bar', 'format': 'asdf'}), # parent path() nesting child path() URLTestPath('/ppath/87/path/42', (), {'parent': 87, 'child': 42, 'foo': 'bar', }), URLTestPath('/ppath/87/path/42.api', (), {'parent': 87, 'child': 42, 'foo': 'bar', 'format': 'api'}), URLTestPath('/ppath/87/path/42.asdf', (), {'parent': 87, 'child': 42, 'foo': 'bar', 'format': 'asdf'}), # parent url() nesting child url() URLTestPath('/purl/87/url/42', (), {'parent': '87', 'child': '42', 'foo': 'bar', }), URLTestPath('/purl/87/url/42.api', (), {'parent': '87', 'child': '42', 'foo': 'bar', 'format': 'api'}), URLTestPath('/purl/87/url/42.asdf', (), {'parent': '87', 'child': '42', 'foo': 'bar', 'format': 'asdf'}), ] self._resolve_urlpatterns(urlpatterns, test_paths)
def get_patterns(self): # self.site.startup() database_ready.send(self.site) urlpatterns = self.get_media_urls() # urlpatterns += patterns( # '', ('^$', self.default_renderer.plugin.get_index_view())) for p in self.site.installed_plugins: if isinstance(p, LinoPlugin): # urlpatterns += p.get_patterns(self) pat = p.get_patterns(self) if p.url_prefix: urlpatterns += patterns( '', url('^' + p.url_prefix + "/?", include(pat))) else: urlpatterns += pat if self.site.django_admin_prefix: # experimental from django.contrib import admin admin.autodiscover() urlpatterns += patterns('', ('^' + self.site.django_admin_prefix[1:] + "/", include(admin.site.urls)) ) return urlpatterns
def add_optional_trailing_slashes(urlpatterns): """ Take a list of urls and add trailing slashes. If slashes already are in regex, make them optional. Based on Django REST Framework apply_suffix_patterns :return: list of urlpatterns :rtype: list[RegexURLPattern] | list[RegexURLResolver] """ urls = list() for pattern in urlpatterns: # check whether URL is nested or not if isinstance(pattern, RegexURLResolver): regex = pattern.regex.pattern.rstrip('$').rstrip('/') patterns = add_optional_trailing_slashes(pattern.url_patterns) namespace = pattern.namespace app_name = pattern.app_name kwargs = pattern.default_kwargs urls.append(url(regex + '$', include(patterns, namespace, app_name), kwargs)) urls.append(url(regex + '/$', include(patterns, namespace, app_name), kwargs)) elif isinstance(pattern, RegexURLPattern): regex = pattern.regex.pattern.rstrip('$').rstrip('/') view = pattern._callback or pattern._callback_str kwargs = pattern.default_args name = pattern.name urls.append(url(regex + '$', view, kwargs, name)) urls.append(url(regex + '/$', view, kwargs, name)) return urls
def get_urls(self): urls = [ url(r"^accounts/", include(self.account_app.urls)), url(r"^", include(self.landing_app.urls)), url(r"^link/", include(self.link_app.urls)), ] return urls
def urlpatterns_maker(**kwargs): path_init = inspect.getouterframes(inspect.currentframe())[1][1] path_views, file_name_init = os.path.split(path_init) path_app, folder_name_views = os.path.split(path_views) app_name = os.path.split(path_app)[1] files = [f.split('.')[0] for f in os.listdir(path_views) if os.path.isfile(os.path.join(path_views, f)) and f.endswith('py') and not file_name_init.startswith(f)] path_list = path_init.split('/') views_index = path_list.index('views') prefix = '.'.join(path_list[views_index-1:-1]) # print(path_init) # print(file_name_init) # print(path_views) # print(path_app) # print(folder_name_views) # print(app_name) # print files # print(files) urlpatterns = patterns('', ) for file_name in files: if file_name in kwargs: urlpatterns += patterns('', url(ur'{0}'.format(kwargs[file_name]), include('{0}.{1}'.format(prefix, file_name))) ) else: urlpatterns += patterns('', url(ur'^{0}/'.format(file_name), include('{0}.{1}'.format(prefix, file_name))) ) return urlpatterns
def setUp(self): class FuzzyApiView(APIView): def get(self, request): pass class ShinyApiView(APIView): def get(self, request): pass api_fuzzy_url_patterns = patterns( '', url(r'^item/$', FuzzyApiView.as_view(), name='find_me')) api_shiny_url_patterns = patterns( '', url(r'^item/$', ShinyApiView.as_view(), name='hide_me')) fuzzy_app_urls = patterns( '', url(r'^api/', include(api_fuzzy_url_patterns, namespace='api_fuzzy_app'))) shiny_app_urls = patterns( '', url(r'^api/', include(api_shiny_url_patterns, namespace='api_shiny_app'))) self.project_urls = patterns( '', url('my_fuzzy_app/', include(fuzzy_app_urls)), url('my_shiny_app/', include(shiny_app_urls)), )
def get_urls(self): urlpatterns = patterns( "", (r"", include(self.blog_app.urls)), (r"^dashboard/", include(self.dashboard_app.urls)), (r"^account/", include(self.account_app.urls)), ) return urlpatterns
def frontend_patterns(): urls = [] for url_obj in UrlPatterns.objects.filter(is_frontend=True): if url_obj.application.name == "admin" or url_obj.application.name == "rest": urls.append(url(url_obj.regex,include(url_obj.path))) else: urls.append(url(url_obj.regex,include(url_obj.path,app_name=url_obj.application.name))) return patterns('',*urls)
def urlpatterns(self): '''load and decorate urls from all modules This is example how use this loader in Django app basically this method is designed to be overwritten, but in the default state loads all urlpatterns and decorate it with require_auth decorator which can be change using ''' # Django-specific: import django now from django.utils.module_loading import module_has_submodule # noqa from django.contrib.auth.decorators import login_required from django.conf.urls import include, url if hasattr(self, "_urlpatterns"): return self._urlpatterns urlpatterns = [] for mod in self.modules: # TODO this not work if self.is_leonardo_module(mod): conf = self.get_conf_from_module(mod) if module_has_submodule(mod, 'urls'): urls_mod = import_module('.urls', mod.__name__) if hasattr(urls_mod, 'urlpatterns'): # if not public decorate all if conf['public']: urlpatterns += urls_mod.urlpatterns else: _decorate_urlconf(urls_mod.urlpatterns, login_required) urlpatterns += urls_mod.urlpatterns # avoid circural dependency # TODO use our loaded modules instead this property from django.conf import settings for urls_conf, conf in getattr(settings, 'MODULE_URLS', {}).items(): # is public ? try: if conf['is_public']: urlpatterns += [url(r'', include(urls_conf))] else: _decorate_urlconf( url(r'', include(urls_conf)), login_required) urlpatterns += [url(r'', include(urls_conf))] except Exception as e: raise Exception('raised %s during loading %s' % (str(e), urls_conf)) self._urlpatterns = urlpatterns return self._urlpatterns
def include_plugins(point, pattern=r"{plugin}/", urls="urls"): pluginurls = [] for plugin in point.get_plugins(): if hasattr(plugin, urls) and hasattr(plugin, "name"): _urls = getattr(plugin, urls) for url in _urls: url.default_args["plugin"] = plugin.name pluginurls.append((pattern.format(plugin=plugin.name), include(_urls))) return include(patterns("", *pluginurls))
def include_notroot_plugins(point, pattern=r'{plugin}/', urls='urls'): pluginurls = [] for plugin in point.get_plugins(): if hasattr(plugin, urls) and hasattr(plugin, 'name'): _urls = getattr(plugin, urls) for url in _urls: url.default_args['plugin'] = plugin.name pluginurls.append(('', include(_urls) )) return include(patterns('', *pluginurls))
def setUp(self): super(ResourceFormatTestCase, self).setUp() # # create a resource as just functions # class TestResourceAsFunc(ModelResource): class Meta(ModelResource.Meta): conduit=( 'conduit.test.conduit_formats.build_pub', 'conduit.test.conduit_formats.return_response', ) model = Bar pk_field = 'id' self.resource_as_func = TestResourceAsFunc() self.resource_as_func.Meta.api = Api(name="v1") self.resource_as_func.Meta.api.register(TestResourceAsFunc()) # # create a resource as a mixin class ( w/ explit paths ) # class TestResourceAsMixin(ModelResource, ConduitBaseMixin): class Meta(ModelResource.Meta): conduit=( 'conduit.test.conduit_formats.ConduitBaseMixin.build_pub', 'conduit.test.conduit_formats.ConduitBaseMixin.return_response', ) model = Bar pk_field = 'id' self.resource_as_mixin = TestResourceAsMixin() self.resource_as_mixin.Meta.api = Api(name="v1") self.resource_as_mixin.Meta.api.register(TestResourceAsMixin()) # # create a recommended resource ( no super class ) # class TestResourceAsContext(ModelResource): class Meta(ModelResource.Meta): conduit=( 'conduit.test.conduit_formats.ConduitBaseMixin.build_pub', 'conduit.test.conduit_formats.ConduitBaseMixin.return_response', ) model = Bar pk_field = 'id' self.resource_as_context = TestResourceAsContext() self.resource_as_context.Meta.api = Api(name="v1") self.resource_as_context.Meta.api.register(TestResourceAsContext()) # override urls self.original_urls = example.urls.urlpatterns example.urls.urlpatterns = patterns( '', url(r'^api_as_func/', include(self.resource_as_func.Meta.api.urls)), url(r'^api_as_mixin/', include(self.resource_as_mixin.Meta.api.urls)), url(r'^api_as_context/', include(self.resource_as_context.Meta.api.urls)) )
def get_urls(self): urlpatterns = super(Main, self).get_urls() urlpatterns += patterns('', url(r"^invoice/", include(self.invoice_app.urls))) urlpatterns += patterns( '', url(r"^[Bb]ooks/", include('oldsite_swapper.urls')) ) return urlpatterns
def get_routes(self): routes = [] first_action = True for action in self.actions: if first_action: routes += patterns('', url('^', include(action.urlpatterns))) first_action = False else: routes += patterns('', url(('^%s/' % action.id), include(action.urlpatterns))) return routes
def get_current_urls(): urls = BaseRouter.get_instance().urls + [ url(r'^auth/', include(auth_patterns)), url(r'^auth/registration/', include(auth_registration_patterns)), url(r'^docs/', include('rest_framework_swagger.urls')), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) if settings.DEBUG: import debug_toolbar urls.append(url(r'^__debug__/', include(debug_toolbar.urls))) return urls
def pelican_urls(): """Helper function to return a URL pattern for serving pelican_admin webservices. """ return ( urls.url(r'^admin/markdown/', urls.include('django_markdown.urls')), urls.url(r'^admin/pelican/', urls.include('pelican_admin.urls')), urls.url(r'^admin/jsi18n.js$', 'django.views.i18n.javascript_catalog', {'packages': 'pelican_admin'}), urls.url(r'^admin/pelican_blog/(?P<path>.*)$', 'django.views.static.serve', {'document_root': os.path.join(settings.PELICAN_PATH, 'output')}), )
def patterns(self, flat=False): urlpatterns = [ url(r'^%s/' % name, include(child.patterns(self.name))) for name, child in self.children.items() ] if flat: return urlpatterns return [ url(r'^%s/' % self.name, include(urlpatterns)), ]
"""project_Aossie URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.11/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 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.urls import url, include from django.contrib import admin urlpatterns = [ url(r'^google_Scholar/', include('google_Scholar.urls')), url(r'^admin/', admin.site.urls), ]
The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.11/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 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.urls import url, include from django.contrib import admin urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^mpemail/', include('mpemail.urls', namespace='mpemail', app_name='mpemail')), ] from django.conf import settings from django.conf.urls.static import static if settings.DEBUG: urlpatterns += [ # ... the rest of your URLconf goes here ... ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') Including another URLconf 1. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) """ from django.conf import settings from django.conf.urls import include, url from django.contrib import admin #import views.py dari folder mysite beserta objectnya from mysite.views import homepage, hello, timesnow, hours_ahead, contact from books import views urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'^$', homepage), #homepage url(r'^hello/$', hello), #hello url url(r'^time/$', timesnow), #time url #cara gobloknya # url(r'^time/plus/1/$', one_hour_ahead), # url(r'^time/plus/2/$', two_hour_ahead), # url(r'^time/plus/3/$', three_hour_ahead), url(r'^time/plus/(\d{1,2})/$', hours_ahead), url(r'^contact/$', contact), # DARI APP books dan folder template url(r'^search-form/$', views.search_form), url(r'^search/$', views.search), ] # if settings.DEBUG:
"""restTutorial URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.11/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 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.urls import url, include from django.contrib import admin urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^', include('snippets.urls')), url(r'^api-auth/', include('rest_framework.urls')), ]
from django.conf.urls import include, url from django.contrib import admin from django.conf.urls.static import static from django.conf import settings urlpatterns = [ url(r'^$', 'thesite.views.home', name='home'), url(r'^contact/$', 'thesite.views.contact', name='contact'), url(r'^thanks/$', 'thesite.views.thanks', name='thanks'), url(r'^shop/', include('shop.urls')), url(r'^ckeditor/', include('ckeditor.urls')), url(r'^blog/', include('blog.urls')), url(r'^admin/', include(admin.site.urls)), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
url(r'category/(?P<category_id>\d+)/$', views.CategoryView.as_view(), name='category-list'), url(r'tag/(?P<tag_id>\d+)/$', views.TagView.as_view(), name='tag-list'), url(r'^search/$', views.SearchView.as_view(), name='search'), url(r'^author/(?P<owner_id>\d+)/$', views.AuthorView.as_view(), name='author'), # RSS和sitemap的url url(r'^rss|feed/', LatestPostFeed(), name='rss'), url(r'^sitemap\.xml$', sitemap_views.sitemap, {'sitemaps': {'posts': PostSitemap()}}), # 搜索框自动补全 url(r'^categoryautocomplete/$', CategoryAutoComplete.as_view(), name='categoryautocomplete'), url(r'^tagautocomplete/$', TagAutoComplete.as_view(), name='tagautocomplete'), # restframework的urls # api/post/ 页面化输出 # api/post/?format=json将数据一json格式输出 # url(r'^api/post/$', apis.PostList.as_view(), name='post_list'), # docs工具的接口 -----------------rest-framework测试 需要安装依赖包 pip install coreapi==2.3.3 url(r'^api/docs/', include_docs_urls(title='typeidea apis')), # 接口文档神器 url(r'^api/', include(router.urls, )) # namespace='api'rest_framework中有的地方并不支持recversehe recverse_acthion 所以使用router ]
from django.conf.urls import url,include from . import views app_name="blogs" urlpatterns=[ url(r'^$',include('home.urls')), url(r'^blogs/$',views.blogs_show_all,name='show_all'), url(r'^blogs/(?P<blog_id>[0-9]+)/$',views.blog_details,name='details'), url(r'^bloggers/$',views.all_bloggers,name='all_bloggers'), url(r'^bloggers/(?P<author_id>[0-9]+)/$',views.blogger_detail,name='blogger_details'), url(r'^blogs/(?P<blog_id>[0-9]+)/create/$', views.add_comment_to_post, name='add_comment_to_post'), url(r'^blogger/$',views.register_blogger,name='register_blogger'), url(r'^blogs/add_post$',views.add_post,name='add_post'), ]
from django.conf.urls import patterns, include, url from cubetube import views from fileupload.views import PictureCreateView from django.contrib import admin from django.conf import settings from django.conf.urls.static import static admin.autodiscover() urlpatterns = patterns('', url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^admin/', include(admin.site.urls)), url(r'^login/', views.login, name='login'), url(r'^newUser/', views.newUser, name='newUser'), url(r'^docs/', views.docs, name='docs'), url(r'^forum/', views.forum, name='forum'), url(r'^flash/(?P<id>\d+)/$', views.flash, name='flash'), (r'^', include('viz.urls')), (r'^', include('comments.urls')), )+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
"""mysite URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.11/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 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.urls import url, include from django.contrib import admin urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^interface/', include('interface.urls', namespace='interface')), ]
Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 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.urls import url from django.conf.urls import include, url from django.conf import settings from django.conf.urls.static import static from django.contrib import admin from boletin import views from .views import about #from boletin.views inicio urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^contact/$', views.contact, name='contact'), url(r'^$', views.inicio, name='inicio'), url(r'^about/$', about, name='about'), url(r'^accounts/', include('registration.backends.default.urls')), ] if settings.DEBUG: urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
"""smsservices URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.11/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 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.urls import url, include from django.contrib import admin urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^/', include('sms.urls', namespace='sms')), ]
"""shortened_link URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.11/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 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.urls import url, include from django.contrib import admin from links.views import HomeView, LinkRedirectView urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^$', HomeView.as_view()), url(r'^(?P<shortlink>[\w-]+)/$', LinkRedirectView.as_view(), name='shortlink'), url(r'^accounts/', include('allauth.urls')), ]
from django.conf.urls import patterns, include, url from django.contrib import admin urlpatterns = patterns( '', url(r'^$', 'lists.views.home_page', name='home'), url(r'^lists/', include('lists.urls')), # url(r'^admin/', include(admin.site.urls)), )
"""testsite URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.9/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') Including another URLconf 1. Add an import: from blog import urls as blog_urls 2. Import the include() function: from django.conf.urls import url, include 3. Add a URL to urlpatterns: url(r'^blog/', include(blog_urls)) """ from django.conf.urls import url, include from django.contrib import admin urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^posts/', include('posts.urls', namespace='posts')), ]
"""{{ project_name }} URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/{{ docs_version }}/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 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.urls import url, include from django.contrib import admin urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^accounts/', include('accounts.urls')), url(r'^social-auth/', include('social_django.urls', namespace='social')), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), url(r'^o/', include('oauth2_provider.urls', namespace='oauth2_provider')), url(r'^api-core/', include('core.urls')), ]
2. Add a URL to urlpatterns: path('home/', Home.as_view(), name='home') Including another URLconf 1. Import the include() function: from django.conf.urls import url, include 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.conf import settings from django.conf.urls import include from django.shortcuts import redirect from django.urls import path from jarbas.core.views import healthcheck urlpatterns = [ path('', lambda _: redirect(settings.HOMES_REDIRECTS_TO), name='home'), path('dashboard/', include('jarbas.dashboard.urls')), path('layers/', include('jarbas.layers.urls', namespace='layers')), path('api/', include('jarbas.core.urls', namespace='core')), path('api/chamber_of_deputies/', include( 'jarbas.chamber_of_deputies.urls', namespace='chamber_of_deputies')), path('healthcheck/', healthcheck, name='healthcheck'), path('dataviz/', include('jarbas.dataviz.urls')), ] if settings.LOG_LEVEL == 'debug': import debug_toolbar urlpatterns = [ path('__debug__/', include(debug_toolbar.urls)), ] + urlpatterns
Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 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.urls import url, include from django.contrib import admin from . import views from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.conf.urls.static import static from django.conf import settings from articles import views as article_views urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^articles/', include( 'articles.urls')), # articles.urls == app name . urls file name url(r'^accounts/', include('accounts.urls')), url(r'^about/$', views.about), # url(r'^$', views.homepage), url(r'^$', article_views.article_list, name="home"), ] urlpatterns += staticfiles_urlpatterns() urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 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.urls import include, url from django.contrib import admin from django.views.generic import TemplateView from django.conf.urls.static import static from django.conf import settings from main import views urlpatterns = [ url(r'^accounts/', include('allauth.urls')), url(r'^admin/', include(admin.site.urls)), url(r'^$', views.main, name="main"), # page d'accueil url(r'^main/', include('main.urls')), url(r'^repository/', include('repository.urls')), url(r'^instrument/', include('instrument.urls')), url(r'^licence/', include('licence.urls')), url(r'^author/', include('author.urls')), url(r'^software/', include('software.urls')), url(r'^administration/', include('administration.urls')), url(r'^lilypondSoftware/', include('lilypondSoftware.urls')), ] urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) handler404 = 'main.errors.error404'
import notifications import autocomplete_light from django.conf.urls import patterns, include, url from django.contrib import admin from django.contrib.auth.views import password_reset from django.views.generic.base import RedirectView from aristotle_mdr.views.user_pages import friendly_redirect_login # import every app/autocomplete_light_registry.py autocomplete_light.autodiscover() admin.autodiscover() urlpatterns = patterns( '', url(r'^', include('aristotle_mdr.urls.base')), url( r'^', include('aristotle_mdr.urls.aristotle', app_name="aristotle_mdr", namespace="aristotle")), url(r'^help/', include('aristotle_mdr.contrib.help.urls')), url(r'^browse/', include('aristotle_mdr.contrib.browse.urls')), ) handler403 = 'aristotle_mdr.views.unauthorised'
from django.conf.urls import url, include from .views import * from django.contrib.auth import views as auth_views # app_name = 'WCFApp' urlpatterns = [ url(r'^$', home, name='home'), url(r'^QuickStart/$', QuickStart, name='QuickStart'), url(r'^documentation/$', documentation, name='documentation'), url(r'^accounts/login/$', auth_views.login, name='login'), url(r'^accounts/logout/$', logout, name='logout'), url(r'^accounts/register/$', register, name='register'), url(r'^accounts/delete/$', deleteAccount, name='deleteAccount'), url(r'^oauth/', include('social_django.urls', namespace='social')), url(r'^settings/$', settings, name='settings'), url(r'^settings/password/$', password, name='password'), url(r'^(?P<api>[a-zA-Z0-9-]+)/inventory/$', inventory, name='inventory'), url(r'^(?P<api>[a-zA-Z0-9-]+)/inventory/(?P<sku>[a-zA-Z0-9-]+)/$', item, name='item'), url(r'^(?P<api>[a-zA-Z0-9-]+)/orders/$', orders, name='orders'), ]
"""disquaire_project URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.11/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 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.urls import include, url from django.contrib import admin #urlpatterns = [ # url(r'^dashboard/', include('dashboard.urls', namespace='dashboard')), # url(r'^admin/', admin.site.urls) #] urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^', include('dashboard.urls')) ]
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 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')) """ # authtest/urls.py from django.conf.urls import include, url from django.contrib import admin # Add this import from django.contrib.auth import views from users.forms import LoginForm from django.conf.urls.static import static from django.conf import settings urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'', include('cal.urls')), # not sure where we want the calendar urls yet url(r'', include('users.urls')), # All urls from users are at the base url(r'^login/$', views.login, { 'template_name': 'users/login.html', 'authentication_form': LoginForm }, name='login'), url(r'^accounts/login/$', views.login, { 'template_name': 'users/login.html', 'authentication_form': LoginForm }, name='login'),
"""mysite URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.10/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 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.urls import include, url from django.contrib import admin urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^jardin/', include('jardin.urls')), ]
"""proj URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.11/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 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.contrib import admin from django.conf.urls import include, url from newapp.views import FileViewSet from rest_framework.routers import DefaultRouter router = DefaultRouter() router.register(r'files', FileViewSet) urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^', include(router.urls)) ]
"""profiles_project URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/2.1/topics/http/urls/ 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 import path from django.conf.urls import include urlpatterns = [ path('admin/', admin.site.urls), path('api/', include('profiles_api.urls')), ]
"""job URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.10/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 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.urls import url, include from django.contrib import admin urlpatterns = [ url(r'^', include('apps.first_app.urls')) ]
"""config URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/2.2/topics/http/urls/ 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.conf.urls import include # 追加 from django.urls import path urlpatterns = [ path('admin/', admin.site.urls), #path('', include('hello.urls')), # 追加 path('', include('webtestapp.urls')), # 追加 ]
"""mySite URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.11/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') 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.urls import include, url from django.contrib import admin urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'', include('blog.urls')), ]
from django.contrib import admin from django.conf.urls import url, include urlpatterns = [ url(r'^admin/', admin.site.urls), url('',include('todo.urls')) ]
name='section-edit'), url(r'^section/(?P<pk>\d+)/delete$', SectionDelete.as_view(), name='section-delete'), url(r'^speeches$', ParentlessList.as_view(), name='parentless-list'), url(r'^recordings$', RecordingList.as_view(), name='recording-list'), url(r'^recording/(?P<pk>\d+)$', RecordingView.as_view(), name='recording-view'), url(r'^recording/(?P<pk>\d+)/edit$', RecordingUpdate.as_view(), name='recording-edit'), url(r'^api/v0.1/recording/$', csrf_exempt(RecordingAPICreate.as_view()), name='recording-api-add'), url(r'^import/popolo', PopoloImportView.as_view(), name='import-popolo'), url(r'^import/akomantoso', AkomaNtosoImportView.as_view(), name='import-akoma-ntoso'), ] if v01_api is not None: urlpatterns += [url(r'^api/', include(v01_api.urls))] urlpatterns += [ url(r'^(?P<full_slug>.+)\.an$', SectionViewAN.as_view(), name='section-view'), url(r'^(?P<full_slug>.+)$', SectionView.as_view(), name='section-view'), ]