Toggling an entire site to private/access denied

There’s already a third-party package for that.

See django-login-required-middleware · PyPI

Note, if you want something easier to toggle without having to change / restart your app, you could also handle this in the nginx layer - see Show external folder html content in django - #2 by KenWhitesell. While this is referencing access to static or media files, nginx doesn’t really care what the resource is. You could use this to protect your application URLs as well.

1 Like