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.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65dd23067cdffc21150add13d8edb5fc06169770a7c2b3cb3e9f9af1d022c0b9 |
|
MD5 | c429533f4026da216f94b958c554dfcc |
|
BLAKE2b-256 | b978e9df064f2a24d17623dfbb429aabd8c0fd4c96c241c9825a6d0fcfe57064 |
Hashes for django_login_required_middleware-0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6fd8b2bcffc25b431603d13fd2d8b7c00121d61a72275c31d56a6283b2cc183 |
|
MD5 | 45ed2a847c8b65b5f01e99a6fbc4368b |
|
BLAKE2b-256 | 6131e706c33382982c9d98cb2db9aa26bedbeab7c2db908446b5a35d44f111da |