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


Python urls.re_path方法代码示例

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


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

示例1: route

# 需要导入模块: from django import urls [as 别名]
# 或者: from django.urls import re_path [as 别名]
def route(pattern, view_func=None, regex=False, *args, **kwargs):
    path_func = re_path if regex else path

    def decorator(view_func):
        if hasattr(view_func, 'as_view'):
            view_func = view_func.as_view()

        urlpatterns.append(path_func(pattern, view_func, *args, **kwargs))
        return view_func

    # allow use decorator directly
    # route('blog/', show_index)
    if view_func:
        return decorator(view_func)

    return decorator 
开发者ID:zenwalker,项目名称:django-micro,代码行数:18,代码来源:django_micro.py

示例2: get_urls

# 需要导入模块: from django import urls [as 别名]
# 或者: from django.urls import re_path [as 别名]
def get_urls(self):
        patterns = []

        for item in self._registry:
            model_class = item['model_class']
            handler_class = item['handler_class']
            prev = item['prev']
            app_label, model_name = model_class._meta.app_label, model_class._meta.model_name

            if prev:
                # patterns.append(re_path(r'^%s/%s/%s/list/$' % (app_label, model_name,prev), handler_class.changelist))
                # patterns.append(re_path(r'^%s/%s/%s/add/$' % (app_label, model_name,prev), handler_class.add_view))
                # patterns.append(re_path(r'^%s/%s/%s/change/(\d+)/$' % (app_label, model_name,prev), handler_class.change_view))
                # patterns.append(re_path(r'^%s/%s/%s/del/(\d+)/$' % (app_label, model_name,prev), handler_class.delete_view))
                patterns.append(
                    re_path(r'^%s/%s/%s/' % (app_label, model_name, prev), (handler_class.get_urls(), None, None)))
            else:
                # patterns.append(re_path(r'^%s/%s/list/$' % (app_label, model_name), handler_class.changelist))
                # patterns.append(re_path(r'^%s/%s/add/$' % (app_label, model_name), handler_class.add_view))
                # patterns.append(re_path(r'^%s/%s/change/(\d+)/$' % (app_label, model_name), handler_class.change_view))
                # patterns.append(re_path(r'^%s/%s/del/(\d+)/$' % (app_label, model_name), handler_class.delete_view))

                patterns.append(
                    re_path(r'^%s/%s/' % (app_label, model_name), (handler_class.get_urls(), None, None)))
        return patterns 
开发者ID:Eeyhan,项目名称:onlinestudy,代码行数:27,代码来源:v1.py

示例3: __init__

# 需要导入模块: from django import urls [as 别名]
# 或者: from django.urls import re_path [as 别名]
def __init__(self):
        self.urlpatterns: List[Union[path, re_path]] = list() 
开发者ID:sazima,项目名称:django-request-mapping,代码行数:4,代码来源:route.py

示例4: update_urlpatterns

# 需要导入模块: from django import urls [as 别名]
# 或者: from django.urls import re_path [as 别名]
def update_urlpatterns(self, clazz, url_patterns_dict):
        for (path_type, full_value), action in url_patterns_dict.items():
            if path_type == 'path':
                self.urlpatterns.append(
                    path(full_value, clazz.as_django_request_mapping_view(action))
                )
            elif path_type == 're_path':
                self.urlpatterns.append(
                    re_path(full_value, clazz.as_django_request_mapping_view(action))
                )
            else:
                raise RuntimeError('not a valid path_type') 
开发者ID:sazima,项目名称:django-request-mapping,代码行数:14,代码来源:route.py

示例5: _fix_path_value

# 需要导入模块: from django import urls [as 别名]
# 或者: from django.urls import re_path [as 别名]
def _fix_path_value(full_value: str, path_type: str) -> str:
        # Remove redundant slants
        full_value = full_value.replace('//', '/', 1)
        if full_value.startswith('/'):
            full_value = full_value[1:]
        if path_type == 're_path':
            full_value = '^' + full_value
        return full_value 
开发者ID:sazima,项目名称:django-request-mapping,代码行数:10,代码来源:route.py

示例6: get_ui_urlpatterns

# 需要导入模块: from django import urls [as 别名]
# 或者: from django.urls import re_path [as 别名]
def get_ui_urlpatterns(ui_urlpatterns):
    return [
        re_path(pattern, ensure_csrf_cookie(IndexView.as_view()), name="index",)
        for pattern in ui_urlpatterns
    ] 
开发者ID:polyaxon,项目名称:polyaxon,代码行数:7,代码来源:__init__.py

示例7: get_urlpatterns

# 需要导入模块: from django import urls [as 别名]
# 或者: from django.urls import re_path [as 别名]
def get_urlpatterns(app_patterns: List, ui_urlpatterns: List):
    if conf.get(ADMIN_VIEW_ENABLED):
        app_patterns += [re_path(r"^_admin/", admin.site.urls)]

    urlpatterns = app_patterns + [
        re_path(r"^healthz/?$", HealthView.as_view(), name="health_check"),
        re_path(r"^50x.html$", Handler50xView.as_view(), name="50x"),
        re_path(r"^permission.html$", Handler403View.as_view(), name="permission"),
        re_path(r"^404.html$", Handler404View.as_view(), name="404"),
    ]
    urlpatterns += get_ui_urlpatterns(ui_urlpatterns)

    return urlpatterns 
开发者ID:polyaxon,项目名称:polyaxon,代码行数:15,代码来源:__init__.py

示例8: distill_re_path

# 需要导入模块: from django import urls [as 别名]
# 或者: from django.urls import re_path [as 别名]
def distill_re_path(*a, **k):
        return _distill_url(re_path, *a, **k) 
开发者ID:meeb,项目名称:django-distill,代码行数:4,代码来源:distill.py


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