2014-12-02 15:17 GMT+01:00 Rootz <arc4g...@gmail.com>: > I have a small Django App using several Class-Based Views but I am > contemplating how the class views would redirect a user based upon a > condition? In my case I would like to redirect user who are not > authenticated. Just how do I go about doing that? > > thanks > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/57d8f675-5336-421a-9f36-aee6e24545ff%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/57d8f675-5336-421a-9f36-aee6e24545ff%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. >
As long as the class based view doesn't require you to be logged in you can achive that by doing: def dispatch(self, request, *args, **kwargs): if not request.user.is_authenticated(): return HttpResponseRedirect(reverse("url_name_to_redirect_to")) # Continue with other dispatch functionality Regards, Andréas -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALXYUb%3D--DDF58S5MMcvo5-RLnekG0UiSVDH2FBxLpN1uqvYcg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.