在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。
安装
假设已安装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 versions | Python versions |
---|---|
2.0 | 3.4, 3.5, 3.6, 3.7 |
2.1 | 3.5, 3.6, 3.7 |
用于旧django/python支持的所有库版本
Django versions | Python versions | Library versions |
---|---|---|
1.4, 1.5 | 2.6, 2.7 | 1.2 |
1.6 | 2.6, 2.7, 3.2, 3.3 | 1.2 |
1.7 | 2.7, 3.2, 3.3, 3.4 | 1.2 |
1.8 | 2.7, 3.2, 3.3, 3.4, 3.5 | 1.3 |
1.9, 1.10 | 2.7, 3.4, 3.5 | 1.3 |
1.11 | 2.7, 3.4, 3.5, 3.6 | 1.4.x (>=1.4.1,<2) |
2.0 | 3.4, 3.5, 3.6, 3.7 | 2.0 |
2.1 | 3.5, 3.6, 3.7 | 2.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装饰包括在开发中)。