Redirect to login when session cookie expires in Django
<p>I'm trying to redirect to the login page when the cookie expires but it's not working.</p>

<p>It's supposed to be as simple as adding these lines to settings.py:</p>

<pre><code>LOGIN_URL = '/login/'
LOGIN_REDIRECT_URL='/login/'
</code></pre>

<p>I'm using the decorator <em>@login_required</em> in my functions and I have tried <em>@login_required(login_url='/login/')</em> too.</p>

<p>Urls are correctly set and when manually going to /login it works, so it's not an error in the path.</p>

<p>When the session cookie expires and you try to access the app it gives you the error 'ViewDoesNotExist' (Could not import django.views.generic.simple.redirect_to. Parent module django.views.generic.simple does not exist.).</p>

<p>Something in your code is trying to import <code>redirect_to</code>, which was removed in Django 1.5. You need to find this code and update it.</p>

python django session cookies