Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

IP number based authentication for Django

Project Description

To install add the middleware to MIDDLEWARE_CLASSES:


You also need to add the authentication backend to AUTHENTICATION_BACKENDS. This will probably not already exist, in which case you will want the entirety of this:


By default it will not authenticate until you also add in the IP numbers that it should allow:

    '', '', # Allow only localhost IP numbers

Currently it will automatically allow the user with ID 1, this is the user that you create during the initial database creation in Django.

There is an optional header to determine which request.META header value to use to get the remote IP number. This defaults to REMOTE_ADDR. If you are behind a HTTP router you may need to set this to something like the X-Forwarded-For:


Make sure that your HTTP router always sets this or you will open the possibility for a remote client to get around the IP number check by just setting a header on the request.

Release History

This version
History Node

History Node


History Node


History Node


History Node


Download Files

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

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(2.4 kB) Copy SHA256 Hash SHA256
Source None Apr 20, 2013

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers