django-decorator-include
raw JSON → 3.3 verified Fri May 01 auth: no python
Include Django URL patterns with decorators. Version 3.3, supports Django 3.0+ and Python >=3.6. Release cadence is low (stable, maintained).
pip install django-decorator-include Common errors
error ImportError: No module named 'django_decorator_include' ↓
cause Using the old import path after upgrading to v3.0+.
fix
Use
from decorator_include import decorator_include instead. error TypeError: decorator_include() got multiple values for argument 'view' ↓
cause Passing a URL pattern directly without wrapping in `include()`.
fix
Use
decorator_include(decorator, include('app.urls')) rather than decorator_include(decorator, path(...)). Warnings
gotcha The decorator is applied to each view function in the included URL patterns, not to the path itself. Ensure decorators are callable and compatible with the view signatures. ↓
fix Use a decorator that works on view functions, e.g., login_required, not a middleware.
deprecated Django 3.0+ required; older Django versions (2.x) are not supported from version 3.0 of this library. ↓
fix Upgrade Django to >=3.0 or use django-decorator-include <3.0.
breaking In version 3.0, the import path changed from `django_decorator_include` to `decorator_include`. ↓
fix Change `from django_decorator_include import decorator_include` to `from decorator_include import decorator_include`.
Imports
- decorator_include wrong
from django_decorator_include import decorator_includecorrectfrom decorator_include import decorator_include
Quickstart
from django.urls import path, include
from django.contrib.auth.decorators import login_required
from decorator_include import decorator_include
urlpatterns = [
path('private/', decorator_include(login_required, include('private_app.urls'))),
]