""" simple middlware to block IP addresses via settings variable BLOCKED_IPS """ from django.conf import settings from django import http class BlockedIpMiddleware(object): def process_request(self, request): if request.META['REMOTE_ADDR'] in settings.BLOCKED_IPS: return http.HttpResponseForbidden('

Forbidden

') return None