在decorators中包含django url模式

django-decorator-include的Python项目详细描述


在decorators中包含django url模式。

由Stéphane“Twidi”Angel和Jon Dufresne负责维护 https://github.com/twidi/django-decorator-include 根据Jeff Kistler的原著 https://github.com/jeffkistler/django-decorator-include

https://badge.fury.io/py/django-decorator-include.svghttps://travis-ci.org/twidi/django-decorator-include.svg?branch=develop

安装

假设已安装pip,请运行以下命令从 PYPI:

pip install django-decorator-include

用法

decorator_include在url confs中用作 django.conf.urls.include函数。它的工作方式与 include,但是第一个参数应该是decorator或 可按相反顺序将装饰器应用于所有包含的视图。在这里 是一个示例url conf:

from django.urls import path
from django.contrib.auth.decorators import login_required

from decorator_include import decorator_include

from mysite.views import index

urlpatterns = [
    path('', views.index, name='index'),
    path('secret/', decorator_include(login_required, 'mysite.secret.urls')),
]

支持的版本

Django versionsPython versions
2.03.4, 3.5, 3.6, 3.7
2.13.5, 3.6, 3.7

用于旧django/python支持的所有库版本

Django versionsPython versionsLibrary versions
1.4, 1.52.6, 2.71.2
1.62.6, 2.7, 3.2, 3.31.2
1.72.7, 3.2, 3.3, 3.41.2
1.82.7, 3.2, 3.3, 3.4, 3.51.3
1.9, 1.102.7, 3.4, 3.51.3
1.112.7, 3.4, 3.5, 3.61.4.x (>=1.4.1,<2)
2.03.4, 3.5, 3.6, 3.72.0
2.13.5, 3.6, 3.72.1

开发

确保您使用的是有效python版本的virtualenv。

从github获取源代码:

git clone -b develop https://github.com/twidi/django-decorator-include.git

然后进入新创建的django-decorator-include目录并安装 所需的少数库:

pip install -r requirements.txt

要运行测试,此库提供了一个测试项目,因此您可以启动 他们这样:

django-admin test --settings=tests.settings tests

或者只需启动runtests.sh脚本(它将运行这个确切的命令):

./runtests.sh

把你的工作建立在develop分支上。IIT应该是上的默认分支 git假设在^{tt8}上使用了-b develop参数$ 命令如上图所示。

创建拉取请求时,请确保使用正确的基 (Twidi/Django装饰包括在开发中)。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何在try块中抛出异常并终止程序   java通过spring boot创建可重用模块   testng上组的java交集。xml   用junit检查Java   netbeans针对Java 5编译web应用程序,但不支持字符串。isEmpty()仍然被允许吗?   使用java显示文件夹中的图像   java如何在输入非数字时修复用户输入错误。下一个双倍?   java Hibernate Hibernate完成saveOrUpdate Vs saveOrUpdateAll   java为什么使用netty循环writeAndFlush发送数据包必须让线程休眠一段时间?   java如何使用onResponse json函数更改安卓片段中的公共字符串值   java DateTimeFormatter严格与宽松的意外行为   java访问neo4jogm的映射上下文   Java使用多个堆栈允许“撤消”方法   java单击图像并对其应用seekbar resize