Skip to main content

A simple Django app which implements blacklists

Project description

This application provide simple blacklist logic for django projects. You can block specific IP-addresses and User Agents for accessing specific page or view-name per HTTP-method. Also, you can configure rules to block users automatically after N requests per datetime.timedelta() and notify site managers about clients which have been blocked!

Quick start

  1. Add “blacklist” to your INSTALLED_APPS setting like this:

  2. Run python migrate to create the blacklists models.

  3. Use blacklisting decorator for views which needs blacklisting logic like this:

    from blacklist.utils import blacklisting
    urlpatterns = (
        url(r'^view/$', blacklisting(log_requests=True)(my_view), name='log'),
  4. Configure AUTO_BLOCKING_RULES setting in your for auto-blocking logic:

            'RULE': {
                'ip': '.*',
            'PERIOD': datetime.timedelta(days=1),
            'BLOCK_AFTER': 10,
            'ENABLED': True,
            'PROPOSAL': True,
            'NOTIFY': (
                ('Mikhail Nacharov', ''),
And call blacklist.models.RequestLog.objects.create_blocking_rules() periodically to create BlockRules. Please use cron via django-cronjobs or setup django-celery for this purpose.

5. If you need email notification configure django email settings as described in If you want to send users site where blocking rules have been created you also need to enable and configure django site framework:


This package is compatible with Django 1.7 and 1.8 and can be ran on python 2.7 and higher.

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-simple-blacklist-0.1.12.tar.gz (15.6 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page