當前位置: 首頁>>代碼示例>>Python>>正文


Python urls.include方法代碼示例

本文整理匯總了Python中django.conf.urls.include方法的典型用法代碼示例。如果您正苦於以下問題:Python urls.include方法的具體用法?Python urls.include怎麽用?Python urls.include使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在django.conf.urls的用法示例。


在下文中一共展示了urls.include方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: waliki_urls

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import include [as 別名]
def waliki_urls():
    base = [url(r'^$', home, name='waliki_home'),
            url(r'^_new$', new, name='waliki_new'),
            url(r'^_get_slug$', get_slug, name='waliki_get_slug'),
            url(r'^_preview$', preview, name='waliki_preview')]

    for pattern in page_urls():
        base.append(url(r'^', include(pattern)))

    base += [url(r'^(?P<slug>' + WALIKI_SLUG_PATTERN + ')/edit$', edit, name='waliki_edit'),
             url(r'^(?P<slug>' + WALIKI_SLUG_PATTERN + ')/delete$',
                 delete, name='waliki_delete'),
             url(r'^(?P<slug>' + WALIKI_SLUG_PATTERN + ')/move$',
                 move, name='waliki_move'),
             url(r'^(?P<slug>' + WALIKI_SLUG_PATTERN + ')/raw$',
                 detail, {'raw': True}, name='waliki_detail_raw'),
             url(r'^(?P<slug>' + WALIKI_SLUG_PATTERN + ')$',
                 detail, name='waliki_detail'),
             ]
    return base 
開發者ID:mgaitan,項目名稱:waliki,代碼行數:22,代碼來源:urls.py

示例2: check_update

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import include [as 別名]
def check_update(request, fields):
    """Checks whether the given request includes fields that are not allowed to be updated.

    :param request: The context of an active HTTP request.
    :type request: :class:`rest_framework.request.Request`
    :param fields: A list of field names that are permitted.
    :type fields: [string]
    :returns: True when the request does not include extra fields.
    :rtype: bool

    :raises :class:`util.rest.ReadOnly`: If the request includes unsupported fields to update.
    :raises :class:`exceptions.AssertionError`: If fields in not a list or None.
    """
    fields = fields or []
    assert (isinstance(fields, list))
    extra = filter(lambda x, y=fields: x not in y, request.data.keys())
    if extra:
        raise ReadOnly('Fields do not allow updates: %s' % ', '.join(extra))
    return True 
開發者ID:ngageoint,項目名稱:scale,代碼行數:21,代碼來源:rest.py

示例3: get_serializer

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import include [as 別名]
def get_serializer(self, *args, **kwargs):

        # Do we wish to include extra detail?
        try:
            kwargs['part_detail'] = str2bool(self.request.GET.get('part_detail', None))
        except AttributeError:
            pass

        try:
            kwargs['sub_part_detail'] = str2bool(self.request.GET.get('sub_part_detail', None))
        except AttributeError:
            pass
        
        # Ensure the request context is passed through!
        kwargs['context'] = self.get_serializer_context()
        
        return self.serializer_class(*args, **kwargs) 
開發者ID:inventree,項目名稱:InvenTree,代碼行數:19,代碼來源:api.py

示例4: get_serializer

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import include [as 別名]
def get_serializer(self, *args, **kwargs):

        # Do we wish to include extra detail?
        try:
            kwargs['part_detail'] = str2bool(self.request.query_params.get('part_detail', None))
        except AttributeError:
            pass
        
        try:
            kwargs['supplier_detail'] = str2bool(self.request.query_params.get('supplier_detail', None))
        except AttributeError:
            pass

        try:
            kwargs['manufacturer_detail'] = str2bool(self.request.query_params.get('manufacturer_detail', None))
        except AttributeError:
            pass
        
        kwargs['context'] = self.get_serializer_context()

        return self.serializer_class(*args, **kwargs) 
開發者ID:inventree,項目名稱:InvenTree,代碼行數:23,代碼來源:api.py

示例5: get_urls

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import include [as 別名]
def get_urls(self):
        urls = [
            url(r'^$', self.index_view.as_view(), name='index'),
            url(r'^catalogue/', include(self.catalogue_app.urls[0])),
            url(r'^reports/', include(self.reports_app.urls[0])),
            url(r'^orders/', include(self.orders_app.urls[0])),
            url(r'^users/', include(self.users_app.urls[0])),
            url(r'^pages/', include(self.pages_app.urls[0])),
            url(r'^partners/', include(self.partners_app.urls[0])),
            url(r'^offers/', include(self.offers_app.urls[0])),
            url(r'^ranges/', include(self.ranges_app.urls[0])),
            url(r'^reviews/', include(self.reviews_app.urls[0])),
            url(r'^vouchers/', include(self.vouchers_app.urls[0])),
            url(r'^comms/', include(self.comms_app.urls[0])),
            url(r'^shipping/', include(self.shipping_app.urls[0])),
            url(r'^refunds/', include(self.refunds_app.urls[0])),
        ]
        urls += self.AUTH_URLS
        return self.post_process_urls(urls) 
開發者ID:edx,項目名稱:ecommerce,代碼行數:21,代碼來源:apps.py

示例6: include

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import include [as 別名]
def include(self, location, namespace=None, app_name=None):
        """
        Return an object suitable for url_patterns.

        :param location: root URL for all URLs from this router
        :param namespace: passed to url()
        :param app_name: passed to url()
        """
        sorted_entries = sorted(self.routes, key=operator.itemgetter(0),
                                reverse=True)

        arg = [u for _, u in sorted_entries]
        return url(location, urls.include(
            arg=arg,
            namespace=namespace,
            app_name=app_name)) 
開發者ID:Visgean,項目名稱:urljects,代碼行數:18,代碼來源:routemap.py

示例7: _buildPatternList

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import include [as 別名]
def _buildPatternList():
  urls = [
    # Main website
    url(r'^', include(SITE_URLS)) if SITE_URLS else None,

    # Main app
    url(r'^', include(MAIN_URLS)),

    # Polychart.js website
    url(r'^js/', include(JS_SITE_URLS)) if JS_SITE_URLS else None,

    # Analytics
    url('^', include(ANALYTICS_URLS)) if ANALYTICS_URLS else None,

    # Deprecated URLs
    url(r'^beta$', permanentRedirect('/signup')),
    url(r'^devkit.*$', permanentRedirect('/')),
    url(r'^embed/.*$', permanentRedirect('/')),
  ]

  # Filter out None
  urls = [x for x in urls if x]

  return patterns('polychart.main.views', *urls) 
開發者ID:Polychart,項目名稱:builder,代碼行數:26,代碼來源:urls.py

示例8: test_namespace_pattern_with_variable_prefix

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import include [as 別名]
def test_namespace_pattern_with_variable_prefix(self):
        """
        Using include() with namespaces when there is a regex variable in front
        of it.
        """
        test_urls = [
            ('inc-outer:inc-normal-view', [], {'outer': 42}, '/ns-outer/42/normal/'),
            ('inc-outer:inc-normal-view', [42], {}, '/ns-outer/42/normal/'),
            ('inc-outer:inc-normal-view', [], {'arg1': 37, 'arg2': 4, 'outer': 42}, '/ns-outer/42/normal/37/4/'),
            ('inc-outer:inc-normal-view', [42, 37, 4], {}, '/ns-outer/42/normal/37/4/'),
            ('inc-outer:inc-special-view', [], {'outer': 42}, '/ns-outer/42/+%5C$*/'),
            ('inc-outer:inc-special-view', [42], {}, '/ns-outer/42/+%5C$*/'),
        ]
        for name, args, kwargs, expected in test_urls:
            with self.subTest(name=name, args=args, kwargs=kwargs):
                self.assertEqual(reverse(name, args=args, kwargs=kwargs), expected) 
開發者ID:nesdis,項目名稱:djongo,代碼行數:18,代碼來源:tests.py

示例9: test_format_api_patterns_url_import

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import include [as 別名]
def test_format_api_patterns_url_import(self):
        urls = patterns('', url(r'api/base/path/', include(self.url_patterns)))
        apis = self.urlparser.get_apis(urls)

        self.assertEqual(len(self.url_patterns), len(apis)) 
開發者ID:Arello-Mobile,項目名稱:py2swagger,代碼行數:7,代碼來源:test_urlparser.py

示例10: test_format_api_patterns_excluded_namesapce

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import include [as 別名]
def test_format_api_patterns_excluded_namesapce(self):
        urls = patterns(
            '',
            url(r'api/base/path/',
                include(self.url_patterns, namespace='exclude'))
        )
        apis = self.urlparser.format_api_patterns(
            url_patterns=urls, exclude_namespaces='exclude')

        self.assertEqual([], apis) 
開發者ID:Arello-Mobile,項目名稱:py2swagger,代碼行數:12,代碼來源:test_urlparser.py

示例11: test_format_api_patterns_url_import_with_routers

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import include [as 別名]
def test_format_api_patterns_url_import_with_routers(self):

        class MockApiViewSet(ModelViewSet):
            serializer_class = CommentSerializer
            model = User
            queryset = User.objects.all()

        class AnotherMockApiViewSet(ModelViewSet):
            serializer_class = CommentSerializer
            model = User
            queryset = User.objects.all()

        router = DefaultRouter()
        router.register(r'other_views', MockApiViewSet, base_name='test_base_name')
        router.register(r'more_views', AnotherMockApiViewSet, base_name='test_base_name')

        urls_app = patterns('', url(r'^', include(router.urls)))
        urls = patterns(
            '',
            url(r'api/', include(urls_app)),
            url(r'test/', include(urls_app))
        )
        apis = self.urlparser.get_apis(urls)

        self.assertEqual(
            4, sum(api['path'].find('api') != -1 for api in apis))
        self.assertEqual(
            4, sum(api['path'].find('test') != -1 for api in apis)) 
開發者ID:Arello-Mobile,項目名稱:py2swagger,代碼行數:30,代碼來源:test_urlparser.py

示例12: setUp

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import include [as 別名]
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)),
        ) 
開發者ID:Arello-Mobile,項目名稱:py2swagger,代碼行數:28,代碼來源:test_urlparser.py

示例13: register_admin_urls

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import include [as 別名]
def register_admin_urls():
    return [
        url(r'^invoices/', include(urls)),
    ] 
開發者ID:SableWalnut,項目名稱:wagtailinvoices,代碼行數:6,代碼來源:wagtail_hooks.py

示例14: get_pattern

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import include [as 別名]
def get_pattern(app_name=app_name, namespace="nyt"):
    """Every url resolution takes place as "nyt:view_name".
       https://docs.djangoproject.com/en/dev/topics/http/urls/#topics-http-reversing-url-namespaces
    """
    import warnings
    warnings.warn(
        'django_nyt.urls.get_pattern is deprecated and will be removed in next version,'
        ' just use include(\'django_nyt.urls\')', DeprecationWarning
    )
    return include('django_nyt.urls') 
開發者ID:django-wiki,項目名稱:django-nyt,代碼行數:12,代碼來源:urls.py

示例15: register_admin_urls

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import include [as 別名]
def register_admin_urls():
    """Adds the administration urls for the personalisation apps."""
    return [
        url(r'^personalisation/', include(
            admin_urls, namespace='wagtail_personalisation')),
    ] 
開發者ID:wagtail,項目名稱:wagtail-personalisation,代碼行數:8,代碼來源:wagtail_hooks.py


注:本文中的django.conf.urls.include方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。