Requiring a Login for an Entire Django Powered Site Redux

November 24, 2006

In an earlier post I had some Django middleware that requires users to be authenticated to use the app. If they’re not logged in they get bounced to the login page. I’ve since updated the code so it’s a little more developer friendly.

Take a look at the source of RequireLoginMiddleware. Set REQUIRE_LOGIN_PATH to your login path, otherwise it uses ’/accounts/login/’ by default.

As always, if you find any errors or have any requests contact me.


Comments

In SVN, you don't need to have a custom setting for the location of the login page - just read LOGIN_URL from settings, as that's also what login_required and such use for where they redirect for login :)

Posted by Collin

Add your comment

No HTML; Only URLs and line breaks are converted.