Redirect anonymous users to log in (don't show them anything)
问题 Django 1.9.6. I want to absolutely disable the whole website from viewing by anonymous users. Anonymous users will always be redirected to login page. I have created a general view. The problem is that subclasses of GeneralView may not just render a template but perform some calculations or just be of different kinds: DetailView, ListView etc. class GeneralView(View): def get(self, request, template): if not request.user.is_authenticated() and request.user.is_active: return redirect("auth