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


Python urls.patterns方法代碼示例

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


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

示例1: get_urls

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import patterns [as 別名]
def get_urls(self):
        urls = super(DocumentSetAdmin, self).get_urls()

        extra_urls = patterns('',
                              url('^(?P<document_set_id>\d+)/answers/$',
                                  self.admin_site.admin_view(self.answers_view),
                                  name="document_set_answers_csv"),
                              url('^(?P<document_set_id>\d+)/add_documents/$',
                                  self.admin_site.admin_view(self.add_documents_view),
                                  name='document_set_add_documents'),
                              url('^(?P<document_set_id>\d+)/update_canons/$',
                                  self.admin_site.admin_view(self.update_canons_view),
                                  name='document_set_update_canons'),
                              url('^(?P<document_set_id>\d+)/reverify_documents/$',
                                self.admin_site.admin_view(self.reverify_documents_view),
                                  name='document_set_reverify_documents')
                             )

        return extra_urls + urls 
開發者ID:crowdata,項目名稱:crowdata,代碼行數:21,代碼來源:admin.py

示例2: static

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import patterns [as 別名]
def static(prefix, view='django.views.static.serve', **kwargs):
    """
    Helper function to return a URL pattern for serving files in debug mode.

    from django.conf import settings
    from django.conf.urls.static import static

    urlpatterns = patterns('',
        # ... the rest of your URLconf goes here ...
    ) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

    """
    # No-op if not in debug mode or an non-local prefix
    if not settings.DEBUG or (prefix and '://' in prefix):
        return []
    elif not prefix:
        raise ImproperlyConfigured("Empty static prefix not permitted")
    return patterns('',
        url(r'^%s(?P<path>.*)$' % re.escape(prefix.lstrip('/')), view, kwargs=kwargs),
    ) 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:22,代碼來源:static.py

示例3: get_url_patterns

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import patterns [as 別名]
def get_url_patterns(self, ):
        prefix = hasattr(self, 'prefix') and self.prefix or ''

        url_patterns = [
            url(r'^'+prefix+'$', self.perms['list'](self.get_list_class_view().as_view()), name=self.list_url_name, ),
            url(r'^'+prefix+'create/$', self.perms['create'](self.get_create_class_view().as_view()), name=self.create_url_name ),
            url(r'^'+prefix+'detail/(?P<pk>\d+)$', self.perms['detail'](self.get_detail_class_view().as_view()), name=self.detail_url_name ),
            url(r'^'+prefix+'update/(?P<pk>\d+)$', self.perms['update'](self.get_update_class_view().as_view()), name=self.update_url_name ),
            url(r'^'+prefix+'delete/(?P<pk>\d+)$', self.perms['delete'](self.get_delete_class_view().as_view()), name=self.delete_url_name ),
        ]

        if django.VERSION >= (1, 8, 0):
            return url_patterns
        else:
            from django.conf.urls import patterns
            return patterns('', *url_patterns) 
開發者ID:spapas,項目名稱:django-generic-scaffold,代碼行數:18,代碼來源:views.py

示例4: _buildPatternList

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import patterns [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

示例5: _get_default_urlpatterns

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import patterns [as 別名]
def _get_default_urlpatterns(self):
        package_string = '.'.join(self.__module__.split('.')[:-1])
        if getattr(self, 'urls', None):
            try:
                mod = import_module('.%s' % self.urls, package_string)
            except ImportError:
                mod = import_module(self.urls)
            urlpatterns = mod.urlpatterns
        else:
            # Try importing a urls.py from the dashboard package
            if module_has_submodule(import_module(package_string), 'urls'):
                urls_mod = import_module('.urls', package_string)
                urlpatterns = urls_mod.urlpatterns
            else:
                urlpatterns = patterns('')
        return urlpatterns 
開發者ID:CiscoSystems,項目名稱:avos,代碼行數:18,代碼來源:base.py

示例6: patterns

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import patterns [as 別名]
def patterns(*args):
        return list(filter(lambda x: x, args)) 
開發者ID:Arello-Mobile,項目名稱:py2swagger,代碼行數:4,代碼來源:__init__.py

示例7: get_sitemessage_urls

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import patterns [as 別名]
def get_sitemessage_urls() -> List:
    """Returns sitemessage urlpatterns, that can be attached to urlpatterns of a project:

        # Example from urls.py.

        from sitemessage.toolbox import get_sitemessage_urls

        urlpatterns = patterns('',
            # Your URL Patterns belongs here.

        ) + get_sitemessage_urls()  # Now attaching additional URLs.

    """
    url_unsubscribe = url(
        r'^messages/unsubscribe/(?P<message_id>\d+)/(?P<dispatch_id>\d+)/(?P<hashed>[^/]+)/$',
        unsubscribe,
        name='sitemessage_unsubscribe'
    )

    url_mark_read = url(
        r'^messages/ping/(?P<message_id>\d+)/(?P<dispatch_id>\d+)/(?P<hashed>[^/]+)/$',
        mark_read,
        name='sitemessage_mark_read'
    )

    if VERSION >= (1, 9):
        return [url_unsubscribe, url_mark_read]

    from django.conf.urls import patterns
    return patterns('', url_unsubscribe, url_mark_read) 
開發者ID:idlesign,項目名稱:django-sitemessage,代碼行數:32,代碼來源:toolbox.py

示例8: get_urls

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import patterns [as 別名]
def get_urls(self):
        """Add URLs needed to handle image uploads."""
        urls = patterns(
            '',
            url(r'^upload/$', self.admin_site.admin_view(self.handle_upload), name='quill-file-upload'),
        )
        return urls + super(QuillAdmin, self).get_urls() 
開發者ID:coremke,項目名稱:django-quill,代碼行數:9,代碼來源:admin.py

示例9: get_urls

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import patterns [as 別名]
def get_urls(self):
        from django.conf.urls import patterns, url
        urls = super(ClipboardAdmin, self).get_urls()
        from .. import views
        url_patterns = patterns('',
                                url(r'^operations/paste_clipboard_to_folder/$',
                                    self.admin_site.admin_view(
                                        views.paste_clipboard_to_folder),
                                    name='filer-paste_clipboard_to_folder'),
                                url(r'^operations/discard_clipboard/$',
                                    self.admin_site.admin_view(
                                        views.discard_clipboard),
                                    name='filer-discard_clipboard'),
                                url(r'^operations/delete_clipboard/$',
                                    self.admin_site.admin_view(
                                        views.delete_clipboard),
                                    name='filer-delete_clipboard'),
                                # upload does it's own permission stuff (because of the stupid
                                # flash missing cookie stuff)
                                url(r'^operations/upload/(?P<folder_id>[0-9]+)/$',
                                    self.ajax_upload,
                                    name='filer-ajax_upload'),
                                url(r'^operations/upload/no_folder/$',
                                    self.ajax_upload,
                                    name='filer-ajax_upload'),
                                )
        url_patterns.extend(urls)
        return url_patterns 
開發者ID:django-leonardo,項目名稱:django-leonardo,代碼行數:30,代碼來源:clipboardadmin.py

示例10: i18n_patterns

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import patterns [as 別名]
def i18n_patterns(prefix, *args):
    """
    Adds the language code prefix to every URL pattern within this
    function. This may only be used in the root URLconf, not in an included
    URLconf.

    """
    pattern_list = patterns(prefix, *args)
    if not settings.USE_I18N:
        return pattern_list
    return [LocaleRegexURLResolver(pattern_list)] 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:13,代碼來源:i18n.py

示例11: get_urls

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import patterns [as 別名]
def get_urls(self):
        urlpatterns = super(ShippingApplication, self).get_urls()
        urlpatterns += patterns('',
            url(r'^city-lookup/(?P<slug>[\w-]+)/$', cache_page(60*10)(self.city_lookup_view.as_view()),
                name='city-lookup'),
        )
        urlpatterns += patterns('',
            url(r'^details/(?P<slug>[\w-]+)/$', cache_page(60*10)(self.shipping_details_view.as_view()),
                name='charge-details'),
        )
        return self.post_process_urls(urlpatterns) 
開發者ID:okfish,項目名稱:django-oscar-shipping,代碼行數:13,代碼來源:app.py

示例12: admin_view

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import patterns [as 別名]
def admin_view(self, view, cacheable=False):
        """
        Decorator to create an admin view attached to this ``AdminSite``. This
        wraps the view and provides permission checking by calling
        ``self.has_permission``.

        You'll want to use this from within ``AdminSite.get_urls()``:

            class MyAdminSite(AdminSite):

                def get_urls(self):
                    from django.conf.urls import patterns, url

                    urls = super(MyAdminSite, self).get_urls()
                    urls += patterns('',
                        url(r'^my_view/$', self.admin_view(some_view))
                    )
                    return urls

        By default, admin_views are marked non-cacheable using the
        ``never_cache`` decorator. If the view can be safely cached, set
        cacheable=True.
        """
        def inner(request, *args, **kwargs):
            if not self.has_permission(request) and getattr(view, 'need_site_permission', True):
                return self.create_admin_view(self.login_view)(request, *args, **kwargs)
            return view(request, *args, **kwargs)
        if not cacheable:
            inner = never_cache(inner)
        return update_wrapper(inner, view) 
開發者ID:madre,項目名稱:devops,代碼行數:32,代碼來源:sites.py

示例13: get_urls

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import patterns [as 別名]
def get_urls(self):
        from django.conf.urls import patterns, url, include
        from xadmin.views.base import BaseAdminView

        if settings.DEBUG:
            self.check_dependencies()

        def wrap(view, cacheable=False):
            def wrapper(*args, **kwargs):
                return self.admin_view(view, cacheable)(*args, **kwargs)
            return update_wrapper(wrapper, view)

        # Admin-site-wide views.
        urlpatterns = patterns('',
                               url(r'^jsi18n/$', wrap(self.i18n_javascript,
                                                      cacheable=True), name='jsi18n')
                               )

        # Registed admin views
        urlpatterns += patterns('',
                                *[url(
                                  path, wrap(self.create_admin_view(clz_or_func)) if type(clz_or_func) == type and issubclass(clz_or_func, BaseAdminView) else include(clz_or_func(self)),
                                  name=name) for path, clz_or_func, name in self._registry_views]
                                )

        # Add in each model's views.
        for model, admin_class in self._registry.iteritems():
            view_urls = [url(
                path, wrap(
                    self.create_model_admin_view(clz, model, admin_class)),
                name=name % (model._meta.app_label, model._meta.model_name))
                for path, clz, name in self._registry_modelviews]
            urlpatterns += patterns('',
                                    url(
                                    r'^%s/%s/' % (
                                        model._meta.app_label, model._meta.model_name),
                                    include(patterns('', *view_urls)))
                                    )

        return urlpatterns 
開發者ID:madre,項目名稱:devops,代碼行數:42,代碼來源:sites.py

示例14: patch_root_urlconf

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import patterns [as 別名]
def patch_root_urlconf():
    from django.conf.urls import include, patterns, url
    from django.core.urlresolvers import clear_url_caches, reverse, NoReverseMatch
    from django.utils.importlib import import_module

    try:
        reverse('tasks:execute')
    except NoReverseMatch:
        root = import_module(settings.ROOT_URLCONF)
        root.urlpatterns = patterns('', url(r'^tasks/', include('django_sae.contrib.tasks.urls', 'tasks',
                                                                'tasks')), ) + root.urlpatterns
        clear_url_caches() 
開發者ID:smallcode,項目名稱:django-sae,代碼行數:14,代碼來源:settings.py

示例15: urls

# 需要導入模塊: from django.conf import urls [as 別名]
# 或者: from django.conf.urls import patterns [as 別名]
def urls(cls):
        base_name = cls.resource_name
        return patterns('',
                        url(r'^$',
                            cls.list_view, name=base_name + '-list')) 
開發者ID:ResEnv,項目名稱:chain-api,代碼行數:7,代碼來源:resources.py


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