A Django middleware that redirects requests based on the current view name for non-staff users.
To install a specific release, replace <tag>
with the desired version tag (e.g., v1.0
):
pip install -e git+ssh://git@github.com/openlibhums/django_view_redirect_middleware.git@<tag>#egg=django_view_redirect_middleware
Alternatively, you can clone the repository and install it locally:
-
Clone the repository:
git clone git@github.com:openlibhums/django_view_redirect_middleware.git
-
Navigate to the directory:
cd django_view_redirect_middleware
-
Install the package:
pip install .
-
Add
'django_view_redirect_middleware.middleware.ViewRedirectMiddleware'
to yourMIDDLEWARE
insettings.py
:MIDDLEWARE = [ # Other middleware... 'django_view_redirect_middleware.middleware.ViewRedirectMiddleware', ]
-
Define
REDIRECT_VIEWS
andREDIRECT_URL_NAME
in yoursettings.py
:REDIRECT_VIEWS = [ 'view_name_1', 'view_name_2', ] REDIRECT_URL_NAME = 'redirect_url_name'
REDIRECT_VIEWS
: A list of view names that should trigger a redirect.REDIRECT_URL_NAME
: The name of the URL to redirect to.
GNU Affero General Public License v3