If this is going to be the case for every single view on your site (i.e. there are no exceptions for help pages or forgotten password views or such), you could probably do it with a custom middleware. But @login_required is probably the best way to go, yeah.
On Nov 15, 11:16 am, CrabbyPete <pete.do...@gmail.com> wrote: > I have a site with lots of views. When someone comes to my site and is > not logged in I direct them to the homepage to login. However a user > could type in a whole url for a view and it will go there and cause an > error because the view expects the user to be logged in. I could put > logic in every view to see if the user is logged in but it seems > redundant. Is there a way to force anonymous users to the home even if > they type in a full url to a specific view -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.