当前位置: 首页>>代码示例>>Python>>正文


Python urls.include函数代码示例

本文整理汇总了Python中django.urls.include函数的典型用法代码示例。如果您正苦于以下问题:Python include函数的具体用法?Python include怎么用?Python include使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了include函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: make_urls

def make_urls(url_fragment, list_view, detail_view, namespace):
    """Register list and detail view for each type of content."""

    return path(url_fragment,
                include((
                    [path('', list_view.as_view(), name='list'),
                     path('<slug:slug>/', detail_view.as_view(), name='detail')],
                    'consulting'),
                    namespace=namespace))
开发者ID:joelburton,项目名称:otessier.com,代码行数:9,代码来源:urls.py

示例2: test_invalid_routes

def test_invalid_routes():
    """
    Test URLRouter route validation
    """
    try:
        from django.urls import include
    except ImportError:  # Django 1.11
        from django.conf.urls import include

    with pytest.raises(ImproperlyConfigured) as exc:
        URLRouter([url(r"^$", include([]))])

    assert "include() is not supported in URLRouter." in str(exc)
开发者ID:andrewgodwin,项目名称:channels,代码行数:13,代码来源:test_routing.py

示例3: get_urls

    def get_urls(self):
        from django.urls import include, path, re_path
        # Since this module gets imported in the application's root package,
        # it cannot import models from other applications at the module level,
        # and django.contrib.contenttypes.views imports ContentType.
        from django.contrib.contenttypes import views as contenttype_views

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

        # Admin-site-wide views.
        urlpatterns = [
            path('', wrap(self.index), name='index'),
            path('login/', self.login, name='login'),
            path('logout/', wrap(self.logout), name='logout'),
            path('password_change/', wrap(self.password_change, cacheable=True), name='password_change'),
            path(
                'password_change/done/',
                wrap(self.password_change_done, cacheable=True),
                name='password_change_done',
            ),
            path('jsi18n/', wrap(self.i18n_javascript, cacheable=True), name='jsi18n'),
            path(
                'r/<int:content_type_id>/<path:object_id>/',
                wrap(contenttype_views.shortcut),
                name='view_on_site',
            ),
        ]

        # Add in each model's views, and create a list of valid URLS for the
        # app_index
        valid_app_labels = []
        for model, model_admin in self._registry.items():
            urlpatterns += [
                path('%s/%s/' % (model._meta.app_label, model._meta.model_name), include(model_admin.urls)),
            ]
            if model._meta.app_label not in valid_app_labels:
                valid_app_labels.append(model._meta.app_label)

        # If there were ModelAdmins registered, we should have a list of app
        # labels for which we need to allow access to the app_index view,
        if valid_app_labels:
            regex = r'^(?P<app_label>' + '|'.join(valid_app_labels) + ')/$'
            urlpatterns += [
                re_path(regex, wrap(self.app_index), name='app_list'),
            ]
        return urlpatterns
开发者ID:Chaoslecion123,项目名称:PythonGroup_11,代码行数:50,代码来源:sites.py

示例4: app_resolver

def app_resolver(app_name=None, pattern_kwargs=None, name=None):
    '''
    Registers the given app_name with DMP and adds convention-based
    url patterns for it.

    This function is meant to be called in a project's urls.py.
    '''
    urlconf = URLConf(app_name, pattern_kwargs)
    resolver = re_path(
        '^{}/?'.format(app_name) if app_name is not None else '',
        include(urlconf),
        name=urlconf.app_name,
    )
    # this next line is a workaround for Django's URLResolver class not having
    # a `name` attribute, which is expected in Django's technical_404.html.
    resolver.name = getattr(resolver, 'name', name or app_name)
    return resolver
开发者ID:doconix,项目名称:django-mako-plus,代码行数:17,代码来源:resolver.py

示例5: path

"""comocomo 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 include, path, re_path
from rest_framework import routers
from gathering import views as gathering_views
from barns import views as barns_views

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/v1/', include('rest_auth.urls')),
    path('api/v1/food-kinds/', gathering_views.FoodKindViewSet.as_view({'get': 'list'}), name='food-kinds'),
    path('api/v1/food-kinds/<kind_id>/food-types/', gathering_views.FoodTypeViewSet.as_view({'get': 'list'}), name='food-types'),
    path('api/v1/food-registrations/', gathering_views.FoodRegistrationView.as_view(), name='food-registrations'),
    path('api/v1/week-statistics/<from_date>/<to_date>/', barns_views.WeekStatisticsView.as_view(), name='week-statistics'),
]
开发者ID:PIWEEK,项目名称:comocomo,代码行数:29,代码来源:urls.py

示例6: path

from django.urls import include, path
from django.contrib import admin

from filebrowser.sites import site

admin.autodiscover()

urlpatterns = [
    path('admin/filebrowser/', site.urls),
    path('grappelli/', include('grappelli.urls')),
    path('admin/', admin.site.urls),
]
开发者ID:sehmaschine,项目名称:django-filebrowser,代码行数:12,代码来源:urls.py

示例7: path

    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, include, re_path
from django.views.generic import TemplateView, RedirectView
from django.conf import settings
from django.contrib.staticfiles.views import serve

from rest_framework_jwt.views import obtain_jwt_token

import os


urlpatterns = [
    path(r'admin/', admin.site.urls),
    # /vpmoapp is now linked to vpmotree as opposed to vpmoapp - vpmoapp to be deleted on vpmotree deployment
    path(r'vpmoapp/', include('vpmotree.urls')),
    path(r'vpmoauth/', include("vpmoauth.urls")),
    path(r"vpmodoc/", include("vpmodoc.urls")),
    # Paths to allow serving the template + static files from ng's build folder
    path(r"", serve, kwargs={'path': 'index.html'}),
    re_path(r'^(?!/?static/)(?!/?media/)(?P<path>.*\..*)$',
        RedirectView.as_view(url='/static/%(path)s', permanent=False))
]
开发者ID:alifrad,项目名称:VPMO,代码行数:30,代码来源:urls.py

示例8: path

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, include
from django.conf.urls.static import static
from django.conf import settings

urlpatterns = [

    path('admin/', admin.site.urls),
    path('', include('market.urls')),
    path('cart/', include('cart.urls')),
    path('mynotes/', include('mynotes.urls')),
    path('settings/', include('settings.urls')),
    path('checkout/', include ('checkout.urls')),
    #path('account/', include('account.urls')),
]




if settings.DEBUG:
    urlpatterns += static(settings.STATIC_URL, document_root = settings.STATIC_ROOT)
    urlpatterns += static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT)

if not settings.DEBUG:
开发者ID:emmanuelcodev,项目名称:ntc_repo,代码行数:31,代码来源:urls.py

示例9: DefaultRouter

router = DefaultRouter()

router.register('one-to-one/places/alchemy', o2o_api.SQLAlchemyPlaceViewSet, 'one-to-one-alchemy|place')
router.register('one-to-one/places/plain', o2o_api.PlainPlaceViewSet, 'one-to-one-plain|place')
router.register('one-to-one/places', o2o_api.PlaceViewSet, 'one-to-one|place')
router.register('one-to-one/restaurants/alchemy', o2o_api.SQLAlchemyRestaurantViewSet, 'one-to-one-alchemy|restaurant')
router.register('one-to-one/restaurants', o2o_api.RestaurantViewSet, 'one-to-one|restaurant')
router.register('one-to-one/waiters/alchemy', o2o_api.SQLAlchemyWaiterViewSet, 'one-to-one-alchemy|waiter')
router.register('one-to-one/waiters', o2o_api.WaiterViewSet, 'one-to-one|waiter')

router.register('many-to-one/reporters/alchemy', m2o_api.SQLAlchemyReporterViewSet, 'many-to-one-alchemy|reporter')
router.register('many-to-one/reporters', m2o_api.ReporterViewSet, 'many-to-one|reporter')
router.register('many-to-one/articles/alchemy', m2o_api.SQLAlchemyArticleViewSet, 'many-to-one-alchemy|article')
router.register('many-to-one/articles', m2o_api.ArticleViewSet, 'many-to-one|article')

router.register('many-to-many/publications/alchemy', m2m_api.SQLAlchemyPublicationViewSet, 'many-to-many-alchemy|publication')
router.register('many-to-many/publications', m2m_api.PublicationViewSet, 'many-to-many|publication')
router.register('many-to-many/articles/alchemy', m2m_api.SQLAlchemyArticleViewSet, 'many-to-many-alchemy|article')
router.register('many-to-many/articles', m2m_api.ArticleViewSet, 'many-to-many|article')

router.register('generic/a', g_api.ModelAViewSet, 'generic|a')
router.register('generic/b', g_api.ModelBViewSet, 'generic|b')

urlpatterns = router.urls


if settings.DEBUG:
    urlpatterns += [
        url(r'^__debug__/', include(debug_toolbar.urls)),
    ]
开发者ID:simone6021,项目名称:django-url-filter,代码行数:30,代码来源:urls.py

示例10: path

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.0/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,include)


urlpatterns = [
    #admin loagin page
    path('admin/', admin.site.urls),
    
    #home page
    path('',include('learning_logs.learn_urls')),
    
    #user page
    path('users/',include('users.users_urls')),

    

]
开发者ID:tudoushell,项目名称:python,代码行数:30,代码来源:urls.py

示例11: path

from django.urls import path, include

from rest_framework import routers
from rest_framework_jwt.views import obtain_jwt_token, refresh_jwt_token, verify_jwt_token

from yaapi.views import BaseAPIView, APIRootView

# from yacommon import views as yacommon_view
from yaapi.views.blog import BlogPostAPIView, BlogPostListAPIView, BlogCategoryAPIView, BlogTagsAPIView, \
    BlogPostArchiveAPIView
from yaapi.views.search import BlogSearchAPIView

router = routers.DefaultRouter()

urlpatterns = [
    path(r'v1/auth/api-auth', include('rest_framework.urls', namespace='rest_framework')),
    path(r'v1/auth/api-token-auth', obtain_jwt_token),
    path(r'v1/auth/api-token-refresh', refresh_jwt_token),
    path(r'v1/auth/api-token-verify', verify_jwt_token),
    path(r'v1/blog-post/<str:title>', BlogPostAPIView.as_view()),
    path(r'v1/blog-posts', BlogPostListAPIView.as_view()),
    path(r'v1/blog-posts/search', BlogSearchAPIView.as_view()),
    path(r'v1/archive', BlogPostArchiveAPIView.as_view()),
    path(r'v1/category', BlogCategoryAPIView.as_view()),
    path(r'v1/tags', BlogTagsAPIView.as_view()),
    # url(r'system/info', yacommon_view.SystemInfo.as_view(), name='system_info'),
    # url(r'blog/resume', yacommon_view.ResumeInfo.as_view(), name='resume_info'),
    path(r"^", include(router.urls)),
]

if settings.DEBUG:
开发者ID:Nicholas86,项目名称:YaDjangoBlog,代码行数:31,代码来源:urls.py

示例12: path

"""simpledemobetterforms 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, include


urlpatterns = [
    path('', include('apps.catalogos.urls')),
    path('admin/', admin.site.urls),
]
开发者ID:alexandermiss,项目名称:simpledemobetterforms,代码行数:23,代码来源:urls.py

示例13: path

from django.conf import settings
from django.contrib import admin
from django.urls import include, path, re_path
from django.views.generic import TemplateView

from tango_shared.views import build_howto

admin.autodiscover()

urlpatterns = [
    path('', TemplateView, {'template_name': 'index.html'}, name='home'),
    path('admin/how-to/', build_howto, name="admin_how_to"),
    path('admin/doc/', include('django.contrib.admindocs.urls')),
    path('admin/', include('admin.site.urls')),
    path('articles/', include('articles.urls.article_urls')),
    #path('comments/', include('tango_comments.urls')),
    path('contact/', include('contact_manager.urls')),
    path('photos/', include('photos.urls')),
    path('events/', include('happenings.urls')),
    # Uncomment if you're using the tango_user app.
    # Or just use your own profiles app.
    # path('profiles/', include('tango_user.urls')),
    path('video/', include('video.urls')),

    re_path(
        route=r'^vote/(?P<model_name>[-\w]+)/(?P<object_id>\d+)/(?P<direction>up|down)vote/$',
        view='voting.views.generic_vote_on_object',
        name="generic_vote"
    ),

    # Map these urls to appropriate login/logout views for your authentication system.
开发者ID:tBaxter,项目名称:tango-starter-kit,代码行数:31,代码来源:urls.py

示例14: path

from django.urls import include, path
from django.contrib import admin

from rest_framework import routers

from invitations import views

router = routers.SimpleRouter()
router.register(r'events', views.EventViewSet)
router.register(r'rsvps', views.RsvpViewSet)

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api-auth/', include(('rest_framework.urls', 'rest_framework'), namespace='rest_framework')),
    path('api/v1/invitations/', include(('invitations.urls', 'invitations'), namespace='invitations')),
    path('api/v2/', include((router.urls, 'router'), namespace='apiv2')),
]
开发者ID:vernistage,项目名称:birthdays-angular,代码行数:17,代码来源:urls.py

示例15: path

from django.urls import include, path
from rest_framework import routers
from rest_framework_jwt.views import obtain_jwt_token

from api.views.users import UserViewSet, GroupViewSet
from api.views.arguments import ArgumentViewSet
from api.views.bigpictures import BigPictureViewSet


router = routers.DefaultRouter()
router.register(r'users', UserViewSet)
router.register(r'groups', GroupViewSet)
router.register(r'arguments', ArgumentViewSet)
router.register(r'bigpictures', BigPictureViewSet)

# Wire up our API using automatic URL routing.
# Additionally, we include login URLs for the browsable API.
urlpatterns = [
    path('api/token-auth/', obtain_jwt_token),
    path('api/', include(router.urls)),
    path('api-auth/', include('rest_framework.urls', namespace='rest_framework'))
]
开发者ID:Diplow,项目名称:thebigpicture,代码行数:22,代码来源:urls.py


注:本文中的django.urls.include函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。