title: Authenticate by IP address in Django
body: <p>I have a small Django application with a view that I want to restrict to certain users. Anyone from a specific network should be able to see that view without any further authentication, based on IP address alone. Anyone else from outside this IP range should be asked for a password and authenticated against the default Django user management.</p>
  
  <p>I assume I have to write a custom authentication backend for that, but the documentation confuses me as the <code>authenticate()</code> function seems to expect a username/password combination or a token. It is not clear to me how to authenticate using IP addresses here.</p>
  
  <p>What would be the proper way to implement IP address-based authentication in Django? I'd prefer to use as much existing library functions as possible for security-related code instead of writing all of it myself.</p>