Created: 2008-10-16 19:35
Updated: 2017-10-13 15:51
License: other


This is a simple application to restrict access to site by IP.


  • Install ipcalc library.

  • Add django_ban in you INSTALLED_APPS.

  • Add option BAN_POLICY:
    BAN_POLICY = 'deny,allow' or BAN_POLICY = 'allow,deny'.

    In first case it means that all users are allowed by default, second case restricts access to all users who not in allow list

    Default value is 'allow,deny'

  • Add 'django_ban.middleware.Ban' to your MIDDLEWARE_CLASSES.

  • Run ./ syncdb, to create necessary tables.

  • Add one or more entries to the Allow or Deny lists in the admin interface. You can just enter a single IP or use a network mask, like this:



  • Add a text description to the list items.
  • Use html template to render Deny page.


This application is based on the Justquick's django snippet. You can find the original code at

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more