Skip to main content

A django middleware to switch between public and protected versions of the same page (url).

Project description


==============================
django-middleware-public-pages
==============================

Use this App to redirect the requests to 'public' alternative of the same view if the user is not logged in.
For example, if there are two views registered:
- page_private (name=page1)
- page_public (name=page1_pub)
If the user is not authenticated, the middleMiddleware will look for a url-name with the same name and the suffix '_pub' and redirect the request.
If the user is authenticated or the 'public' URL is not found, the Middleware has no effect.


Quick start
-----------

1. Install the app:


1. Add it to your INSTALLED_APPS setting like this::

INSTALLED_APPS = [
...
'django-middleware-public-pages',
]

2. Add the middleware at the end of the list in settings::

MIDDLEWARE_CLASSES = (
...
"django-middleware-public-pages",
)

3. Configure two views, one for authenticated user e.g. page_private and another
for anonymous or public (page_public)::

urlpatterns += [
url("^page_private/$", views.Page1View.as_view(), name="page1"),
url("^page_public/$", views.Page2View.as_view(), name="page1_pub"),
...
]

The middleware will automaticaly redirect "/page_private" to "/page_public" if the user is not
authenticated.
Attention: important is the name of the view and not the url-path.

Project page - https://gitlab.com/rristow/django-middleware-public-pages.git


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-middleware-public-pages-0.14.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file django-middleware-public-pages-0.14.tar.gz.

File metadata

  • Download URL: django-middleware-public-pages-0.14.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.6

File hashes

Hashes for django-middleware-public-pages-0.14.tar.gz
Algorithm Hash digest
SHA256 a99e54aa3db5a27a59e898d1a8074708849efe3d00ada5d7f489ae9eda1b2769
MD5 47d55df9ced883f3b0bfd73c8e28ac98
BLAKE2b-256 f71cf671b2a3784b24ea5b28dd0d6da619ad6ae36197afa14e541aa022169dd9

See more details on using hashes here.

File details

Details for the file django_middleware_public_pages-0.14-py3-none-any.whl.

File metadata

  • Download URL: django_middleware_public_pages-0.14-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.6

File hashes

Hashes for django_middleware_public_pages-0.14-py3-none-any.whl
Algorithm Hash digest
SHA256 0fd2f8194cb8490203fa2666f65a0b948bea9eea23d5bf7503690260f94d172f
MD5 3a16a4914d2d214422d228055935ebe2
BLAKE2b-256 1e84ecf36bec0bc661fce56e818a3be992e839a2680e35fd8bd5b70daf1200b0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page