Requires login to all requests through middleware.
Project description
django-login-required-middleware
django-login-required-middleware provide login to all requests through middleware.
If the website has many views and almost all use
LoginRequiredMixin
or the login_required
decorator, using django-login-required
can keep the code of your views more clear and avoids forgetting authentication of view.
Requirements
- Python: 3.6, 3.7
- Django: 1.11, 2.0, 2.1, 2.2, 3.0x
Quick start
-
Install
pip install django-login-required-middleware
-
Add
'login_required'
in yourINSTALLED_APPS
setting. -
Add
login_required.middleware.LoginRequiredMiddleware
toMIDDLEWARE
afterdjango.contrib.auth.middleware.AuthenticationMiddleware
-
(Optional) Add
LOGIN_REQUIRED_IGNORE_PATHS
setting.
Any requests which match these paths will be ignored. This setting should be a list filled with regex paths (settings.LOGIN_URL
always included).Example:
LOGIN_REQUIRED_IGNORE_PATHS = [ r'accounts/logout/$' r'accounts/signup/$', r'about/$' ]
-
(Optional) Add
LOGIN_REQUIRED_IGNORE_VIEW_NAMES
setting. Any requests which match these url name will be ignored. This setting should be a list filled with url names.Example:
LOGIN_REQUIRED_IGNORE_VIEW_NAMES = [ 'home', 'login', 'namespace:url_name', ]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-login-required-middleware-0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 075c55a16b0a8debe893feb6e3c35b217ce06de771c26e7947103c236edab015 |
|
MD5 | 265b20d3057be61e95a80df5a64e03e1 |
|
BLAKE2b-256 | 98821c544616ea5ac0d0c9dc4767f8381edb4d01dcad8b922ff089d2f827333a |
Hashes for django_login_required_middleware-0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15b55836d3d8b73a9759e350fad9c9bd638109dcdebc8645f6809aa5dbcec81e |
|
MD5 | 237195ec1436401fde53f49b02d3345f |
|
BLAKE2b-256 | 815fa1bc176b9dd595f22eb7c5ef007b223ddb03bd435fe310824396333577d6 |