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 au
IMO, solving this with Django is fine if it's a small non performance critical site.
It's better to keep the unauthorized users fully at bay using your Apache or Nginx service. For example, in Nginx I have these lines in my site configuration:
include allowed_ips.conf;
deny all;
error_page 403 forbidden.html;
allowed_ips.conf is in /etc/nginx and looks (something) like this:
allow 110.222.333.222; # J Bloggs (sys admin)
allow 777.222.0.0/16; # Government owned
...
I believe this is better because the relatively slow Django processes never get touched by the blocked IPs. This is significant if you are blocking bots or other country address ranges for performance or security reasons.