The task is simple:
If user visits site root then:
if user is authenticated then:
redirect to /dashboard/
else:
redirect to settings.LOGIN_URL
There are many ways to implement that, but I wonder if there is such way in which I do need to use only urls.py.
I found a solution with RedirectView login_required(RedirectView.as_view(url=my_url)), however then I can only write static my_url instead of reverse(), which is not flexible.
You could use
reverse_lazy(Django 1.4) in you url configuration, like so:Another possibility is to define
LOGIN_URLusingreverse_lazy, so you could continue to usesettings.LOGIN_URLin your redirects.Code is untested, might have a typo somewhere.