當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。