Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Blocks access to the Django admin pages unless requests come from specific IP addresses

Project description

Django Admin Restrict

Build Status Latest PyPI version

django-adminrestrict enables you to block access to the Django admin pages unless requests come from specific IP addresses.


django-adminrestrict requires Django 1.4 or later. The application is intended improve the security around the Django admin login pages.


Download and install django-adminrestrict using one of the following methods:


You can install the latest stable package running this command:

$ pip install django-adminrestrict


You can install the latest stable package running:

$ easy_install django-adminrestrict


You can contribute to this project forking it from github and sending pull requests.


First of all, you must add this project to your list of INSTALLED_APPS in


Next, install the FailedLoginMiddleware middleware:


Create the appropriate tables in your database that are necessary for operation.

For django(<1.7), run python syncdb.

For django(>=1.7), run python makemigrations adminrestrict; python migrate.

IMPORTANT: When the package is configured in your project, an empty table called AllowedIP will be created in your database. If this table is empty or has one record with a “*” the package will not restrict any IPs. If you want to add specific restrictions please go to the next section.


Using django-adminrestrict is extremely simple. Once you install the application and the middleware, all you need to do is update the allowed IP addresses AllowedIP section of the admin pages.

Adding allowed IP addresses

Login to the admin pages and browse to the Adminrestrict app, and start creating recorded in the AllowedIP table. Just type in the IP addresses and save records.

Adding allowed IP addresses with wildcards

Create a AllowedIP entries ending with a “*” to any IPs that start with the specified patterh. For example, adding 192.* would allow addreses starting matching 192.*.*.* to login to the admin pages.

Adding * to disable all restrictions

Create a single AllowedIP record with “*” as the IP address, to temporarily disable restrictions. In this way, you do not have to modify and remove the middleware if you need to disable.

Having at least one AllowedIP record with * as the IP address effectively disables all restrictions.

Project details

Download files

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

Files for django-adminrestrict, version 2.0
Filename, size File type Python version Upload date Hashes
Filename, size django_adminrestrict-2.0-py2-none-any.whl (8.0 kB) File type Wheel Python version py2 Upload date Hashes View hashes
Filename, size django-adminrestrict-2.0.tar.gz (6.8 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page