The role of the middleware is to present a user friendly error page when a rule denied process of the request by raising Denied.

class rules_light.middleware.Middleware[source]

Install this middleware by adding rules_light.middleware.Middleware` to settings.MIDDLEWARE_CLASSES.

process_exception(request, exception)[source]

Render rules_light/exception.html when a Denied exception was raised.


{% extends 'rules_light/base.html' %}

{% load i18n %}

{% block body %}
	<div class='rules_light' >
		{% trans 'You do not have permission to do that.' %}

		{% if settings.LOGIN_URL %}
		<a href="{{ settings.LOGIN_URL }}?next={{ request.path_info|urlencode }}">{% trans 'Try logging in' %} {% if request.user.is_authenticated %}{% trans 'with other credentials' %}{% endif %}</a>
		{% endif %}
{% endblock %}