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, 3.8
- Django: 1.11, 2.0, 2.1, 2.2, 3.0x
Quick start
-
Install
pip install django-login-required-middleware
-
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'/admin/$', r'/admin/login/$', 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', 'admin:index', 'admin: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.5.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44c7e66e2048b8282c83fefed9de15085f8bef161ec4254da12a03b50ac24a7c |
|
MD5 | 28d04cfcf2d870722bfd601910f48c8c |
|
BLAKE2b-256 | 16cd73c332bc83e49dfcff3dc9ab224915b9ad25ce08a11d0f4613b99330d211 |
Hashes for django_login_required_middleware-0.5.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb9fa217d7ebdbd7726e23771e4ae8ddc3afb07dc135af4743cdd2bf7cd3b8af |
|
MD5 | 9c89006f9c24b2538cb21623054a8cfc |
|
BLAKE2b-256 | b122ea0000a6ee2a9155650f3470ee9b05112271c8a2f57eb131ce3b44322f87 |